A close-range header from Portugal substitute Ricardo Quaresma secured a 1-0 win over Croatia after the game burst into life late in extra time on Saturday and set up a Euro 2016 quarter-final against Poland next week.
Quaresma struck three minutes from the end of the extra period after a Cristiano Ronaldo shot was brilliantly saved by Danijel Subasic to settle the tie just a minute after Croatia's Ivan Perisic had hit the post with a header.
Croatia almost snatched an equaliser at the death but Domagoj Vida hooked the ball agonisingly wide.
Porugal coach Fernando Santos said: "Both teams were here expecting to win every match, all the way to the final. This was a final. We won, and when you win you're lucky. Sometimes you don't win and you're unlucky. Today, we were the lucky ones."
Croatia manager Ante Cacic added: "We expected Portugal to counter and we were playing really well for 120 minutes, controlling the match, not conceding any chances except the last one that was our mistake and we were punished for that."
There was some lovely one-touch play from both sides but plenty of passes also went astray in a tense, cagey last 16 game in which neither side managed to register a shot on target until Ronaldo's late effort led to the winning goal.
Croatia were on top for most of the first half but Portugal had the first chance when Pepe headed Raphael Guerreiro's free kick over the bar after Ronaldo was tripped by Perisic.
Perisic, who had a patch of his hair dyed to match the red-and-white checked pattern of his shirt, then cut in from the right but he dragged his shot outside the near post.
Luka Modric and Mario Mandzukic returned from injury for Croatia, with Mandzukic spurning an excellent first-half chance when he headed Dario Srna's corner wide of the target.
With Mandzukic on his own up front and Nani and Ronaldo shackled, neither side could break the deadlock and a smattering of boos and whistles were heard at the halftime whistle.
Croatia continued to dominate possession after the break, but their wasteful finishing continued as Marcelo Brozovic narrowly failed to connect with Ivan Strinic's cross and then followed up by blazing over from the resulting corner.
Substitute Renato Sanches registered Portugal's first shot of the second half when he broke forward and played a one-two with Joao Mario but steered the ball wide of the target.
Croatia centre-back Vida then had a glorious chance to give his side the lead on the hour but headed wide with the goal at his mercy and Mandzukic lurking behind him.
Earning his 100th cap, Nani had a penalty appeal turned down when he went sprawling in the box under pressure from Strinic.
Ronaldo did not fare much better and, despite occasional flashes of skill, he was kept quiet for most of the game.
The match finished scoreless and went into extra time with Nikola Kalinic, who replaced Mandzukic, blasting a shot wide halfway through the first period.
Croatia still looked livelier and Vida was frustrated again as he headed another corner just over with Portugal keeper Rui Patricio stranded after coming out for the cross.
Perisic flashed the ball across the goal and then saw a header come back off the post before Portugal countered and Ronaldo's shot was parried into the path of Quaresma who scored.
Croatia poured forward in search of an equaliser and Vida made it a hat-trick of misses as he hooked the ball wide leaving Portugal to go through to face Poland in Marseille on Thursday.