A Jason Cummings penalty and Liam Fontaine header put the hosts 2-0 up before Kyle Benedictus pulled a goal back late on for the visitors who finished the game with 10 men after Dylan Tait was sent off.
Rovers went into the match knowing that a point against James McPake’s side would be enough to secure second place in the Championship table, while the home side were hoping to secure a place in the top four.
Boss John McGlynn made two changes from last Saturday’s win over Alloa with Dan Armstrong and Adam King dropped out to be replaced by Jamie Gullan and Kieran MacDonald.
There was a place on the bench for Lewis Vaughan but Frankie Musonda and Ross Matthews missed out due to injury.
The first ten minutes were evenly matched with neither side able to fashion an opening until the home side took the lead on 12 minutes.
A Cummings attempt was blocked by the arm of Rovers captain Benedictus and ref Willie Collum pointed to the spot.
The striker himself took the penalty and sent Jamie MacDonald the wrong way to open the scoring.
The next 15 minutes were a drab, scrappy affair with neither side able to penetrate the other’s defence, so it was no surprise that the next goal came courtesy of a set piece and unfortunately for the Stark’s Park side, it was scored by Dundee
A Paul McGowan corner was headed in by an unchallenged Liam Fontaine.
Raith were up against it now, with the home side growing in confidence and taking command of the match but a Regan Hendry shot from long distance on 39 minutes was close to bringing the visitors back into it.
The sides went in at the break with Rovers trailing 2-0 and with it all to do in the second half.
Neither side made a change during the interval and the match settled into the same pattern as the first half, with the teams cancelling each other out and precious little goalmouth action.
The first chance of note from either side came on 67 minutes when a superb first time back heel from Gozie Ugwu put Hendry through but his shot was straight at keeper Adam Legzdins - Rovers’ first attempt on target.
Four minutes later and they came agonisingly close to pulling a goal back.
A cross from Reghan Tumilty was met at the back post by sub Lewis Vaughan, who had replaced Kai Kennedy, but he put his effort wide.
Rovers had the best of the final quarter but just couldn’t find a way through the Blues’ well organised defence until 87 minutes when they gave themselves a lifeline.
A Hendry cross was partially deflected and Benedictus stooped to head a goal back.
Raith tried to grab a last-gasp equaliser but instead found themselves down to ten men on 91 minutes when Dylan Tait sent off for a two-footed challenge on Paul McGowan.
The top four places are now confirmed after Dunfermline got the better of Arbroath but the battle for second will now go down to the wire on Friday between with Raith and Dundee with Rovers ahead by just a point.
The Tayside team will travel to play Queen of the South whilst Raith welcome champions Hearts knowing that a point may not be enough to take that runners up spot and, crucially, miss out on having to play two extra games in the Premiership play-off.