Portugal survived a fright and a fine Croatia performance to win 2-1 in Toronto and move into the last 16 of the World Cup, scoring twice in the second half after falling behind. The winner arrived deep into stoppage time, when Gonçalo Ramos rose to head home, NBC Sports reported — a dramatic finish to what was the last World Cup match staged in the Canadian city.

How it unfolded

Croatia, the seasoned tournament side led by the veteran Luka Modrić, took the lead through Ivan Perišić early in the second half, rewarding a disciplined display. Portugal, who had been kept quiet before the break, needed a response — and got one from the most familiar source. Cristiano Ronaldo drew his team level from the penalty spot just past the hour, keeping Portugal's campaign, and his own, alive.

The equalizer set up a tense finish. Ronaldo thought he had turned the game around entirely when the ball hit the net again, but the goal was ruled out for offside — by the narrowest of margins, replays suggesting little more than a shoulder had strayed beyond the last defender, as the BBC noted. For a moment it looked as if Portugal might have to settle for extra time.

Instead, in the fourth minute of added time, Rafael Leão delivered a cross and Ramos climbed above the Croatia defense to head Portugal in front. There was no time for a reply. Portugal were through; Croatia, and Modrić, were out.

The end for a golden generation

For Croatia, the defeat closes a chapter. Modrić, one of the finest midfielders of his era and the driving force behind a small nation's remarkable run of deep tournament finishes, exits a World Cup that will likely be his last on this stage. Their campaign ended not for want of effort — they led, and pushed Portugal hard — but on the fine margins that decide knockout football.

Portugal, for their part, showed the resilience that a serious contender needs. Falling behind in a knockout tie and finding a way back, with a mix of Ronaldo's penalty composure and a substitute's late intervention, is the sort of escape that can define a tournament run.

A tie to savor next

The reward is a meeting with Spain in the round of 16 — a fixture between two of the sport's traditional powers and neighbors on the Iberian Peninsula. Spain reached this stage with a comfortable 3-0 win over Austria, and arrive as one of the favorites; Portugal will fancy their chances of springing a surprise, particularly with Ronaldo still finding decisive moments.

It is the kind of last-16 tie that would not look out of place in a final, and it guarantees that one of the two Iberian sides will be gone before the quarter-finals.

A fitting farewell

There was a valedictory note to the occasion beyond the football. The match was Toronto's last of this expanded, multi-nation World Cup, and the host city sent its tournament off with a genuine thriller — late drama, a disallowed goal, a legend keeping his story going and another closing his. Portugal move on to bigger tests; the memory of the night, and of Modrić's last World Cup bow, will linger a while longer.