Stephan El Shaarawy’s 14th-minute goal looked set to give Eusebio Di Francesco’s side all three points as Napoli failed to convert their numerous chances and found Roma goalkeeper Robin Olsen in superb form.
But with time running out substitute Mertens, who had two earlier efforts ruled out for offside, reacted quickest to Jose Callejon’s mishit shot to slam the ball into the roof of the net.
After kick-off was delayed by several minutes due to a problem with the VAR system, Napoli were the first to threaten as Fabian Ruiz embarked on a mazy run through the Roma defence.
However, just as he manoeuvred himself into a shooting position, Ruiz opted to set up team-mate Lorenzo Insigne, who saw his shot deflected over the bar.
At the other end Edin Dzeko flashed a right-foot shot just wide and seconds later Roma took the lead as Cengiz Under’s cross found El Shaarawy completely unmarked and he fired the visitors ahead off the inside of the post.
Napoli responded well to going behind and Arkadiusz Milik saw his shot well saved by Roma goalkeeper Robin Olsen, with Insigne then flagged offside as he tried to put away the rebound.
Marek Hamsik then drew two more good saves out of the impressive Olsen before Dzeko almost doubled Roma’s lead after running on to Under’s through ball and rounding David Ospina, although the goalkeeper forced Dzeko wide and his left-foot shot was headed off the line by Raul Albiol.
Roma’s hopes of victory suffered a major blow shortly before half-time when captain Daniele De Rossi was forced off through injury to be replaced by Bryan Cristante, with Dzeko taking the captain’s armband.
Dzeko did not exactly cover himself in glory in the role and was booked for a dive 10 minutes into the second half, which Roma would spend the majority of which defending stoically.
Mertens twice had the ball in the net only to be correctly flagged for offside on each occasion, but it was third time lucky in the last minute when Callejon failed to connect properly with Insigne’s cross and Mertens was alert enough to fire home from close range.