After a disappointing 90 minutes and first half of extra-time, the last 16 round game finally came to the life in the last 10 minutes.
A drab contest in Lens looked to be heading to penalties until Quaresma headed home from a few yards out in the 117th minute after Cristiano Ronaldo’s shot had been saved.
Less than a minute earlier, Ivan Perisic had almost given Croatia the lead when he headed against the post.
The contest was a turgid affair for much of the 120 minutes.
Croatia controlled the ball in the early stages but rarely pushed forward, and although Portugal gained a foothold after 15 minutes, they were equally tentative.
The best chance of the first half came in the 25th minute after Ronaldo was fouled on the wing. Raphael Guerreiro sent in a well-placed cross from the free kick, but Pepe’s powerful header sailed over the bar.
Portugal’s play improved when Renato Sanches came on for Andre Gomes. His 20-yard shot was wide after a one-two with Joao Mario, but it underlined how desperate viewers were for action at the time.
Croatia didn’t have that final ball for much of the game, but on three occasions got through for headers before messing it up by failing to head on target.
Darijo Srna headed wide and seemed to take the chance away from Mandzukic. Portugal had Nani through in the 64th minute but instead of chesting and shooting, he played it with his shoulder and then tried to appeal for a penalty.
Croatia’s Domagoj Vida and Marcelo Brozovic went close with headers, and Ivan Perisic’s effort hit the bar late on. It was that move that caught them off guard for the late goal, as Ronaldo was open on the right. The Real Madrid man’s shot was saved, but that assist led to the winner.
Portugal’s last-eight match against Poland will take place at the Stade Velodrome in Marseille on Thursday.