The Real Madrid man converted an early penalty, but Spain hit back through Costa. Ronaldo struck again just before half-time, courtesy of a blunder from David de Gea, but Costa and Nacho Fernandez―who gave away the early penalty―were on point after the break.
A Spanish win seemed inevitable, but Ronaldo completed his hat-trick late with a wonderful free-kick.
Here are the key takeaways from this match.
Ronaldo Saves Portugal, But He'll Need More Help
Ronaldo played one of his best-ever outings in his national shirt on Friday, and it went well beyond the three goals. The Real striker was a constant nuisance on the counter and even did his defensive duties for large stretches of the match, putting a lot of pressure on Nacho.
It speaks to his considerable talent that Portugal were able to salvage a draw against a dominant Spanish side. Apart from a solid start and strong finish, the Portuguese were thoroughly outplayed by La Roja, and it's hard to point at another individual who actually put in a great performance.
With an in-form Ronaldo, Portugal will always be a threat, but far more is needed from the rest of the team. It takes four wins in the knockout stages to win a world title, and the Selecao can't rely on their star man to bail them out every time.
Portugal certainly have the talent, and if Joao Moutinho or Bernardo Silva can step up their level, there's no reason they can't win the whole thing.
Hierro's Big Decisions Pay Off
Fernando Hierro's first XI would always be closely scrutinised, as the former Real Madrid man had little time to assess his squad after replacing Julen Lopetegui on Wednesday.
He opted to take few risks, playing Costa ahead of Iago Aspas at striker and putting Real's Nacho in at right-back. A natural centre-back, he was a bit of an odd fit, but as explained by AS' Robbie Dunne, he was seen as perhaps a safer option than Real Sociedad's Alvaro Odriozola:
The much faster Odriozola would likely have done a better job keeping up with Ronaldo in the first half, and Nacho's supposed superior defensive ability was in serious doubt after he brought down his Los Blancos team-mate after just minutes, giving away a silly penalty.
But if Hierro's choices seemed wrong after 15 minutes had been played, both Costa and Nacho turned things around. The former scored twice after a slow and sloppy start, and Nacho gave La Roja the lead with a thunderous strike after the break.
Costa's ability to hold up play made all the difference against the reliable but static duo of Pepe and Jose Fonte, and Nacho's aerial ability served the Spaniards well on both sides of the pitch. For a caretaker manager who only got the job days ago, Hierro surely made some impressive decisions.
De Gea Needs to Block Out Noise after Another Error
Manchester United stopper De Gea may have the reputation of one of the best goalkeepers in the world, but a number of errors have crept into his game this season. He had high-profile blunders at the club level―his mistake against Sevilla comes to mind―but things have escalated since the end of the 2017-18 campaign.
There was the mistake against Switzerland in a friendly on June 3, after which he had this to say, per Dunne:
Unfortunately for the former Atletico Madrid man, he made another costly error on Friday, one that gifted Ronaldo his second goal. De Gea couldn't have picked a worse time to go into a slump, and he needs to bounce back quickly.
The Spanish press was already on him after the Switzerland match, and things will only get worse after this. De Gea can't let that affect him, especially once the knockout stages begin.
Pepe's Mental Error
Fans will likely debate Costa's equaliser for a long time, and there's certainly an argument the goal should not have stood. Sports writer Karl Matchett did not think his shove on Pepe was a foul, but there were plenty who disagreed:
It all could have been avoided if Pepe had played the situation a little smarter, however. The Besiktas man went down into a heap as soon as Costa made contact with him, but he got back up again a few seconds later, unable to help his team-mates as the striker struck.
The whole point of the video assistant referee is that officials can go back to assess a situation―if Pepe had been fouled, he should have stayed on his feet, continued to defend and consult the official after the play was over. Instead, Pepe tried to milk the contact, and it cost him and his team.
Guedes Is Not Ready
Goncalo Guedes is a phenomenal talent who stood out in Portugal's final warm-up matches, but on Friday, he struggled tremendously against Spain's quality defenders.
In the first half, the Paris Saint-Germain man ruined several promising counter-attacks with either poor touches or indecisiveness. Ronaldo, in particular, grew frustrated as the half wore on, and it was easy to see why―the 33-year-old did a sensational job creating space on counters, only to watch Guedes lose the ball.
The 21-year-old's time will come, but perhaps it would be best to move him to the bench for now and use him as a high-energy substitute.
Both teams will be in action on Wednesday, with Portugal facing Morocco and Spain taking on table-toppers Iran.