Roma 3 Genoa 2: Perotti hits winner on Totti's farewell
Francesco Totti bowed out with a dramatic victory as Diego Perotti's last-minute winner gave Roma a 3-2 home Serie A win over Genoa that secured a second-place finish.
In an unbelievable ending to the game, Daniele De Rossi fired in with a powerful finish to seemingly seal victory, only for Darko Lazovic to score a header and threaten to spoil the party.
But Roma were not to be denied, Perotti scoring in the final minute to ensure they beat Napoli to second - the third time in four years they have been runners-up - and ensured they will qualify automatically for the Champions League group stage.
On an emotional day, Roma legend Totti, 40, came off the substitutes's bench in his last match more than 24 years after making his debut for the club.
Fans will now wait to see if he takes up a new role at the club or opts for a final playing stint elsewhere, while head coach Luciano Spalletti also faces an uncertain future amid big speculation linking him with the Inter job.
Pietro Pellegri, the 16-year-old who earlier this season became the joint-youngest player in Serie A history, scored his first senior goal after just three minutes as Genoa threatened to steal the show.
But Edin Dzeko's 29th goal of the season brought Roma level and ensured he will finish the season as the league's top scorer.
Roma needed a win order to secure second spot, with Napoli romping to a 4-2 win at Sampdoria and Dzeko set up De Rossi before Lazovic's prompt response at the other end.
However, Perotti's strike ensured Roma and Totti would celebrate a dream victory on the veteran's farewell.
Genoa threatened a shock when Pellegri raced clear of Kostas Manolas to latch onto a throughball from Lazovic and slot a low, first-time finish past Wojciech Szczesny.
And it was almost two as Roma made a shaky start, Raffaele Palladino firing wide after Szczesny had taken a major risk in charging out of his goal.
But the hosts were level after 10 minutes when Kevin Strootman chipped into Dzeko, whose initial left-footed effort struck the post before he threw his body at the ball to bundle in the rebound.
Roma saw Emerson Palmieri carried off on a stretcher with what looked like a serious knee injury, but that did not halt their momentum as Dzeko forced a save from Eugenio Lamanna and Stephan El Shaarawy sent an effort narrowly wide soon after, Strootman the creator on each occasion.
Dzeko then had a penalty claim turned down just before the break when he was challenged by Genoa captain Santiago Gentiletti at the far post as he tried to turn in Strootman's cross.
Totti was brought on for Mohamed Salah in the 54th minute, as some fans applauded and others were reduced to tears.
The veteran made a positive impact, setting up Strootman to drill a long-range effort just wide before his cross led to El Shaarawy's header forcing a super save from Lamanna.
And Roma finally got in front with 16 minutes remaining, with Strootman finding Dzeko, whose impressive cut-back set up De Rossi to fire in left-footed and delight the home crowd.
But Genoa levelled five minutes later against the run of play, Diego Laxalt's floating cross from the left catching out Szczesny and allowing Lazovic to net with a simple header from close range.
Szczesny then did enough to deflect a Lazovic effort onto the post as a thrilling encounter continued.
But Roma had the last word, Radja Nainggolan's cross being flicked on by both Federico Fazio and Dzeko, with Perotti lashing in from six yards against his former club.