Filip Djordjevic thought he had secured a point for the hosts when he cancelled out Juan Iturbe's strike, but Mapou Yanga-Mbiwa popped up with a late winner
Lazio's place in the Champions League is still not secure after they were beaten 2-1 by arch-rivals Roma on Monday.
With Napoli losing 3-1 at champions Juventus on Saturday, Lazio knew a point would be enough to see them clinch third place in Serie A make a return to Europe's premier club competition after a seven-year absence.
But Lazio were undone by their biggest foes at Stadio Olimpico after a pulsating second half.
Juan Iturbe gave Roma the lead in the 73rd minute, only for Filip Djordjevic to level eight minutes later with a close-range header.
However, Roma, playing as the visitors in this fixture, had the last laugh five minutes from time when defender Mapou Yanga-Mbiwa rose highest to head Miralem Pjanic's free-kick into the bottom-left corner and net his first goal for the club.
The result sets up a mouthwatering final-day clash between Lazio and Napoli at the Stadio San Paolo. Napoli are three points behind Lazio and - despite an inferior goal difference - would finish third with a win courtesy of a better head-to-head record.
Miroslav Klose had the best chance of a fiery first half in the fifth minute, but the Lazio striker sent his unmarked header wide.
Victor Ibarbo fired narrowly off target from a corner in the 70th minute, yet the Roma substitute atoned for that miss by getting to the byline and pulling back for Iturbe to flick home three minutes later.
Roma's lead was brief, though, as Lazio produced a well-worked equaliser, Djordjevic nodding home after Klose had headed Felipe Anderson's far-post ball back across goal.
Yet there was to be one last sting in the tail when France international Yanga-Mbiwa leapt to turn Pjanic's whipped delivery beyond the outstretched arm of Lazio goalkeeper Federico Marchetti.