Empoli had failed to win any of its previous nine away league games yet took the lead inside five minutes at San Siro through Andrea Pinamonti, who is on loan from Inter.
Inter was two goals behind when Kristjan Asllani fired in, but Martinez struck after ex-Milan man Simone Romagnoli had put into his own net to level up before half-time.
Martinez completed the comeback in the 64th minute and Alexis Sanchez added a late fourth as Inter moved one point above Milan, which travels to Hellas Verona on Monday (AEST).
Pinamonti slid in to meet Szymon Zurkowski's cross and give Empoli an early lead, the striker proving true to his word by not celebrating the goal.
Asllani had a goal ruled out for an offside infringement but, after Inter had a penalty awarded and then ruled out by VAR (video assistant referee), the youngster brilliantly controlled a pass and fired home.
But Romagnoli's own goal when trying to cut out Federico Dimarco's cross gave Inter hope and Martinez guided in a first-time shot five minutes later to wipe out Empoli's lead.
Martinez's second arrived after a sustained spell of Inter pressure, the Argentina striker volleying past Guglielmo Vicario after Riccardo Fiamozzi only half-cleared the ball.
Sanchez then added some gloss to the scoreline in stoppage-time when converting a pass from fellow substitute Edin Dzeko.