Roma's 11th win of the campaign tightened their grip on second spot in the Serie A.
With Juventus in Super Cup action in Doha this Friday against AC Milan but facing a relatively easy fixture with Crotone on their return, both Roma and Napoli were keen to stay on their tails in the final fixtures of 2016.
El Shaarawy was given a rare start by coach Luciano Spalletti and the former Milan forward paved the way for a classy win with an incisive free kick on the stroke of half-time that levelled Jonathan De Guzman's 37th minute opener.
"His goal was a decisive factor for us," Spalletti later told Sky Sport.
Roma were superb after the break and Edin Dzeko fired the hosts into a 52nd minute lead with his 13th goal of the campaign.
The Bosnian is now just one behind Serie A leader Mauro Icardi, who hit a brace for Inter Milan in a 3-0 win over Lazio on Wednesday.
Dzeko spurned several chances to tie and perhaps surpass Icardi in the later stages, before Diego Perotti put the result beyond doubt with a penalty on the stroke of full-time.
Roma's 11th win of the campaign tightened their grip on second spot and, although Juventus will be expected to restore their seven-point advantage when they face Crotone in their catch-up fixture in early February, the Giallorossi have stolen a march on Napoli.
"The lads were brilliant tonight, from the first minute to the last," gushed Spalletti.
"There was a slight risk after our defeat (to Juventus) last week but the lads went out and showed how much they wanted the points."
A last-gasp penalty from Manolo Gabbiadini saw Napoli grab a share of the spoils in a 3-3 draw at Fiorentina that nonetheless saw them drop two precious points.
Napoli remain third but are seven points behind Juventus, three behind Roma and one ahead of Lazio. AC Milan are fourth at one point further behind, but also have a catch-up game, away to Bologna, in February.
After two consecutive defeats for Fiorentina, Napoli had a decisive swagger after a beautiful strike from Lorenzo Insigne flew over the head of Ciprian Tatarusanu and into the far corner of the Fiorentina net on 25 minutes.
There was a hint of offside, and Fiorentina coach Paulo Sousa later hit out at the decision: "It happens, but all of us have to improve and we also have to help the referees to get better.
"We did well to fight our way back, but we deserved to win."
But then Federico Bernardeschi's 52nd minute free-kick deflected off Jose Callejon's elbow to wrong-foot Pepe Reina in the Napoli net.
Napoli looked to be back in command when Dries Mertens flicked a Faouzi Ghoulam cross past Tatarusanu in the 68th minute to restore the visitors' one-goal advantage, the Belgian remarkably hitting his eighth goal in just three games.
Later, Mertens hit out at the state of Fiorentina's pitch.
"Unfortunately my goal wasn't enough. We played fairly well on a pitch that was in terrible condition. Usually it's fine, but tonight it was horrible.
"It's a shame, we had chances to win this game."
But Napoli's joy was short-lived.
Bernardeschi hit a ferocious strike that went in off the inside of the far post just a minute later and when Mauro Zarate met a Bernardeschi chip with a crisp right-foot volley on 82 minutes the hosts looked to have snatched the win.
Napoli grabbed a share of the spoils when Gabbiadini, who came off the bench minutes earlier, stepped up to beat Tatarusanu from the spot following a Carlos Salcedo foul on Mertens in the area.