Steven Craig's late goal secured victory for Partick Thistle and sent them two points clear at the top of the First Division.
Thistle fell behind when Raith Rovers' Greig Spence fired home from 10 yards.
Strikes by Stuart Bannigan and Steven Lawless turned the match in the hosts' favour before half-time.
Brian Graham's tap-in levelled the match on 81 minutes but Craig swept a shot into the net three minutes from the end to give Jackie McNamara's side all three points.
Partick: Smith, Muirhead, Balatoni, Archibald, Sinclair, Lawless, Paton, Bannigan, Forbes, Erskine (McGuigan 69), Craig. Subs Not Used: Scully, Doolan, Murray, Rowson.
Goals: Bannigan 21, Lawless 32, Craig 87.
Raith: Laidlaw, Thomson, Ellis, Malone, Hill, Grant Anderson, Hamill, Walker, Smith (Clarke 76), Graham, Spence. Subs Not Used: McGurn, Stuart Anderson, Callachan, Donaldson.
Booked: Thomson, Ellis.
Goals: Spence 13, Graham 81.
Ref: Kevin Clancy