Inter were left reeling when Andrea Pinamonti fired a fifth-minute opener for the visitors, who proceeded to double their lead through Kristjan Astlani just before the half-hour mark.
But an own goal by Simone Romagnoli gave the hosts hope and Martinez pulled them level at 2-2 on the stroke of half-time.
Inter took charge after the break, with Martinez pouncing on a rebound to grab his second of the night in the 64th minute and Alexis Sanchez sealing the win in injury time.
The points proved enough for Simone Inzaghi’s men to go back to the top with two games remaining, but city rivals AC Milan can reclaim top spot on Sunday against Verona.
Struggling Genoa boosted their survival hopes in dramatic fashion as they scored twice in the last three minutes to sink fourth-placed Juventus 2-1.
The visitors, who were hoping to leapfrog Napoli into third, led through Paulo Dybala’s effort on the stroke of half-time, but Albert Gudmundsson equalised on 87 minutes and Domenico Criscito’s injury-time penalty sealed the win.
It lifts Genoa level with third-bottom Cagliari and one point off safety with two games of their season remaining.
A last-gasp penalty also gave Levante hope of avoiding the drop from LaLiga as they beat Real Sociedad 2-1.
The hosts led through Jorge Miramon’s 53rd-minute opener and after David Silva equalised, Melero’s late spot-kick moved Levante above Alaves and three points from safety.
In Ligue 1, two goals from Aurelien Tchouameni lifted Monaco two places from fourth to second with a 2-1 win at Lille, who had levelled through Angel Gomes.
Arminia Bielefeld are on the brink of relegation from the Bundesliga after they were beaten 2-1 at Bochum.
Sebastian Polter’s opener for the hosts was cancelled out by Joakim Nilsson’s header but a late own goal from George Bello means Bielefield are two points behind Stuttgart in the play-off position with just one game remaining. They would be relegated on Sunday if Stuttgart win, though that game is away at champions Bayern Munich.