Ricardo Quaresma scored in the 117th minute as Portugal booked their spot in the quarter-finals of Euro 2016 with a 1-0 win over Croatia in Lens on Saturday night.
A disappointing last-16 tie appeared to be heading for a penalty shootout, but Quaresma headed home three minutes before the end of extra-time to send Fernando Santos's team into the final eight.
Boosted by the return of Luka Modric, it was Croatia that made the brighter start to proceedings in Lens, but neither team created a chance of note during what was a tight and tense opening 15 minutes of international football.
Portugal appeared to find their rhythm as play developed, but Cristiano Ronaldo and Nani were struggling to get into the match due to a deep and stern Croatian backline, led by the strong Vedran Corluka.
It was Portugal that created the first chance of real note in the 25th minute when Raphael Guerreiro picked out the head of Pepe with a free kick from the left, but the centre-back headed over the crossbar under little pressure.
Croatia's first opportunity arrived on the half-hour mark when Ivan Perisic raced away from Guerreiro down the right before cutting inside and attempting to pick out the near post, but the ball hit the side-netting.
Like Modric, Mario Mandzukic also returned from injury to start for Croatia, but the Juventus striker headed his best chance of the first period over the crossbar 10 minutes before the break.
There were only four attempts in the first 45 minutes in Lens and neither goalkeeper had a save to make. Croatia shaded the possession with 60%, but neither team did enough in the first half to deserve to enter the break with a lead.
Croatia had a wonderful chance to take the lead in the 52nd minute when Ivan Rakitic delivered a short corner in to Marcelo Brozovic after the Portuguese defence had gone to sleep, but the midfielder fired over from close range.
Four minutes later, Modric had the chance to threaten from a long-range strike, but the Real Madrid midfielder missed the crossbar, before Renato Sanches fired a low strike wide of the post down the other end.
Croatia again came close just past the hour when Domagoj Vida met a wicked delivery from Darijo Srna, but the ball flew wide of the post as Portugal survived another dangerous moment in the second period.
Portugal had a strong shout for a penalty in the 64th minute when Nani went down inside the box under a challenge from Vida, but the referee was not interested. It was Santos's side that continued to search for the opening goal during a strong period, although Croatia remained a threat on the counter-attack.
Neither team were prepared to throw caution to the wind as the final 10 minutes approached, however, and extra time arrived after what was perhaps the most disappointing 90 minutes of action at this summer's tournament.
It was Croatia that started the extra-time period on the front foot and Perisic came close with a clever header five minutes into the first half, but his effort was just too high of Rui Patricio's net, before Nikola Kalinic missed from inside the box.
The second half of extra time started still without a single shot on target and there were no indications that one would arrive as both teams continued to struggle in the final third of the field.
Vida had a wonderful chance to win it for Croatia in the final minutes when Patricio missed a corner from the left, but the centre-back headed wide of the target, before Perisic hit the post from close range, moments after delivering a dangerous cross towards Kalinic.
There was to be heartbreak on the counter-attack for the Croatians, however, as Nani's low strike fell to Ronaldo and his effort was saved straight into the path of Quaresma, who headed home to set up a quarter-final with Poland next Thursday in Marseille.