UEFA Champions League: Shakhtar 2 Porto 2
Shakhtar looked destined for victory after Luiz Adriano tapped in with five minutes to go to add to the lead given to them earlier in the second half by Alex Teixeira.
However, Porto, who had a Yacine Brahimi first-half penalty saved by Andriy Pyatov, staged a stunning late fightback.
They were given a lifeline in the final minute when Yaroslav Rakitskiy was penalised for handball in the box and substitute Martinez tucked in the resulting spot-kick.
And Porto claimed the unlikeliest of points when Martinez, who had been introduced in the 65th minute, stole in at the near post to finish Cristian Tello's low cross in the 93rd minute.
The draw extends Porto's unbeaten start to the season and gives them a point to add to the three they earned in the first round of Group H matches, courtesy of their 6-0 home win over BATE.
While Porto took full advantage of the numerous chances that came their way against BATE, Julen Lopetegui's men were wasteful in the extreme at Shakhtar on Tuesday until the dying moments.
Perhaps assisted by the fact that this game was played 760 miles away from Shakhtar's Donbass Stadium as a result of the unrest in Ukraine, Porto played with far greater authority than expected for an away side.
This enabled them to create a string of openings, including two in the first 10 minutes, with Vincent Aboubakar pulling an effort wide from 20 yards before Danilo went even closer with a shot of his own from further out, after having nipped in to steal the ball following a misplaced Shakhtar pass.
Midway through the half, Porto were given an even better chance to open the scoring when they were awarded a penalty for Oleksandr Kucher's trip on Brahimi.
The Algeria midfielder, who scored a hat-trick against BATE, took the spot-kick himself, but placed it at a good height and too close to Pyatov, who dived to his right to palm it away.
Porto finished the half by spurning another great chance as Tello ended a marauding run forward with a shot past the far post.
However, the away side gifted Shakhtar the lead after 52 minutes.
Oliver Torres dwelt on the ball, allowing Kucher to steal it in the Porto box and draw out Fabiano before playing a square ball to Teixeira for the simplest of finishes into an empty net.
For the remainder of the game, Porto launched a siege on the Shakhtar goal, with Brahimi, Juan Quintero and Martinez all denied by the excellent Pyatov.
Porto's chance of claiming anything from the game looked to have gone with five minutes to go when Shakhtar hit them on the break and Adriano tapped home Bernard's pass at the back post.
However, Porto refused to give in and their persistence was rewarded when Rakitskiy handled in the box and Martinez slotted home from the spot before the same player found himself in the perfect place to tap in and rescue a point with the 2-2 draw.