With the game looking to be heading for a 2-2 draw with four minutes remaining, second-half substitute Mirko Vucinic came to the rescue by scoring twice to fire Roma to victory.
Marco Borriello had given the hosts a fifth-minute lead before Catania's Matias Silvestre equalised before the half-hour mark.
Maxi Lopez put the Sicilians in front in the 38th minute but Borriello made it 2-2 shortly after the restart.
The win sees Roma move to fourth place, two points behind city rivals Lazio, who were held to a goalless draw at Genoa.
The hosts could not have asked for a better start as they broke the deadlock early on.
Catania goalkeeper Mariano Andujar saved Daniele De Rossi's bullet strike but failed to hold on to the ball and Borriello made no mistake from close range.
The visitors reacted and could have equalised in the 24th minute had Lopez's 30-yard effort not gone just wide of the far post.
Catania's efforts paid off in the 29th minute.
Silvestre's header from Cristian Llama's cross beat Roma goalkeeper Julio Sergio.
The goal inspired the visitors, who took the lead before the break.
Alexandro Gomez fed Lopez inside the area and his right-footed strike went past Julio Sergio.
Catania's joy was shortlived as Roma levelled the score in the 47th minute.
There was nothing Andujar could do to save Borriello's close-range header from John Arne Riise's cross.
Roma continued to push forward and Borriello should have given his team the lead in the 84th minute but he struck straight to the keeper from a good position.
The hosts' efforts paid off two minutes later.
A fast counter-attack by the Eternal City giants surprised the visitors, with Totti serving an unmarked Vucinic inside the area and he fired past Andujar to put his team in front.
With seconds left to play, Vucinic struck his second of the afternoon.
Totti again acted as provider, leaving Vucinic inside the area to fire past Andujar.