As far as parting gifts go, Toronto received one of the World Cup’s best matches so far on Thursday night as it signed off as a 2026 host city, with Portugal edging Croatia 2-1 in an instant classic.

Portugal superstar Cristiano Ronaldo got the goal that the 43,036 in attendance had come to see, but that was only sufficient to cancel out the opener from Croatia’s Ivan Perisic. The real drama arrived in second-half stoppage time, as substitute Gonçalo Ramos rose above a thicket of defenders to head Portugal into the last 16 and a matchup with Spain.

Just 22,089 fans were present the last time Ronaldo played a game at BMO Field, scoring once while wearing an unfamiliar No. 9 – Raul had the No. 7 shirt back then – as Real Madrid cruised to a 5-1 preseason victory over Toronto FC in 2009.

Fast forward 17 years and Ronaldo was back, in a far more important setting – in a World Cup stadium with almost double the capacity – with a place in the last 16 at stake. Tickets were a little bit pricier as a result – the get-in price on some resale sites hovered around $2,500 earlier on Thursday, with the maximum soaring up towards six figures.

Cathal Kelly: Even in its decline, The Ronaldo Show is worth the inflated price of admission

After the whistle: Canada Soccer enjoying World Cup renewal

Croatia captain Luka Modric wasn’t part of the Madrid lineup that day. He wouldn’t join Los Blancos until 2012, but together, Ronaldo and Modric – arguably the best footballers produced by their respective countries – enjoyed a run of huge success, combining for four Champions League titles, with both laying claim to Ballon d’Or crowns as the world’s best player along the way.

That shared history formed much of the backdrop to this round-of-32 match, with the long-time teammates and their countries’ respective captains sharing hugs before and after exchanging team pennants ahead of the opening kickoff. With a combined age of 81, and both part of the exclusive 200-plus-cap club, they were likely aware that one of them was about to play their last World Cup match.

Based on the first half, it didn’t seem like it would be Portugal heading home. The world’s fifth-ranked team pushed the tempo from the start, and should have taken the lead inside four minutes. However, Croatia goalkeeper Dominik Livakovik got down well to parry Bruno Fernandes’s one-time effort from a Rafael Leão cross, with centre-back Marin Pongracic blocking the Manchester United midfielder’s follow-up attempt.

Open this photo in gallery:

Portugal's Cristiano Ronaldo, right, puts his hand on Croatia's Luka Modric after Portugal advanced to the round of 16 at the World Cup. The former club teammates seemed to know that for one of them, this would be their final World Cup match.Frank Gunn/The Canadian Press

With Ronaldo looking to add an elusive World Cup crown to the European one he captured back in 2016, his teammates now do a lot of tireless legwork for him, much like Argentina did for Lionel Messi four years ago.

Playing in his sixth World Cup, the 41-year-old had a couple of decent chances to find the net in the first 45 minutes. On the first, he was inches away from connecting with a Pedro Neto cross at the nine-minute mark, and 20 minutes later he couldn’t react quick enough to get anything on a João Cancelo ball into the box.

With much of the attention understandably focused on Ronaldo and Modric, fans would be forgiven for forgetting about another of the old guard on display. Much of the Portugal defenders forgot about 37-year-old Ivan Perisic too, and after a cross from Josip Stanisic skipped off the head of Rúben Dias, the veteran found himself unmarked with the ball at his feet in the 53rd minute. He had time to take a couple of touches before firing a left-footed shot past Diogo Costa in the Portugal goal.

Open this photo in gallery:

Both Ronaldo (7) and Modric (10) are over 40 and were desperately hungry to keep their World Cup dreams alive.Mike Stewart/The Associated Press

The match increased in tempo at that point. Both Croatia and Portugal had goals ruled out, with an offside call preventing Igor Matanovic from doubling Croatia’s lead, while Ronaldo saw his neat control and finish ruled out for having his shoulder slightly ahead of the play.

In between, Leão crashed a shot off the crossbar.

With Portugal coach Roberto Martinez making four substitutions on the hour mark as his looked for a way back into the match, his prayers were answered shortly afterwards.

Following a video review, Croatia’s Nikola Vlasic was judged to have rugby-tackled Portugal’s Renato Veiga on a free kick played into the box, and the referee pointed to the spot.

Open this photo in gallery:

Portugal's Gonçalo Ramos (9) heads home what stood as the match-winner on Thursday night in Toronto, as his team held off Croatia in an intense round of 32 battle.Sam Balkansky/The Associated Press

Ronaldo stepped up, crashing his penalty down the middle of the goal as Livakovic obligingly dived to his right, giving the Portugal captain his first World Cup knockout goal in his 26th match at the tournament.

With 15 minutes remaining, Portugal was saved by the upright as Mateo Kovacic crashed a shot that Costa managed to divert onto the post, with Costa again called into action to tip over a volley from the Manchester City midfielder seconds after.

And the offside flag came to Portugal’s rescue again minutes later as Petar Sucic’s goal is called back.

Ronaldo subbed off in the 81st minute to a rousing reception from the fans, but it was one of the earlier substitutes that swung the match in Portugal’s favour, with Ramos heading home a Leão cross in the fourth minute of added time.

A frantic end saw Croatia substitute Josko Gvardiol bundle the ball into the net, but the goal was ruled out for yet another offside following a VAR check, as water bottles rained down from a south stand full of unhappy Croatian fans, with Portugal moving on to Dallas to play Spain.

Follow related authors and topics

Authors and topics you follow will be added to your personal news feed in Following.

Interact with The Globe