The Colombian striker hit a left-footed diagonal shot past Napoli goalkeeper Pepe Reina to give his side the edge heading to Italy next week.
Carlos Eduardo had previously beaten Reina in the opening half but his goal had been disallowed for offside.
The victory at the Dragao stadium maintained a perfect start for new coach Luis Castro, who replaced Paulo Fonseca last week after his promotion from the B team and claimed a 4-1 win against Arouca in his debut.
The hosts had the first chance in the 12th minute when Eduardo released Martinez into the area but Reina dived and saved his 10-yard shot.
Shortly after, Reina kept out Steven Defour's bullet strike from the edge of the box.
In the 20th minute, Porto thought they had taken the lead when Eduardo headed Martinez's cross past Reina but the goal was flagged for offside.
Before the half-hour mark, Antoine Reveillere did well to get park his marker but his dangerous cross failed to find a Napoli team-mate in the penalty box, with Maicon's header from Ricardo Quaresma's free-kick going wide before half-time.
The home side continued to press forward after the restart and in the 47th minute, Fernando's 30-yard drive was kept out by Reina.
Napoli first tested Helton in the 53rd minute when Jose Callejon passed to Gonzalo Higuain in the six-yard box, only for his powerful shot to be saved by the Porto goalkeeper.
In the 54th minute, Helton again came to the rescue to deny Raul Albiol after he headed Callejon's corner-kick on target.
Just when Napoli looked more dangerous, Porto went ahead. Napoli failed to clear a corner-kick and Martinez was first to the loose ball and fired the ball past a helpless Reina.
The visitors almost equalised in the 67th minute when Callejon spotted Higuain in the box but the Argentinian failed to beat Helton in a one-on-one situation.
With seven minutes remaining, Maicon made a goal-line clearance from substitute Duvan Zapata's goal-bound attempt with Helton already beaten.