Portugal progressed to the World Cup knockout stages after drawing with Iran in a game full of VAR controversy.

Cristiano Ronaldo missed a penalty for Portugal and was shown a yellow card after a lengthy VAR review for a possible red card.

Iran scored a late penalty, given after another video review, and almost snatched a winner in stoppage time which would have seen them not only go through at Portugal's expense but also top the group, with Spain held to a 2-2 draw by Morocco.

Ricardo Quaresma had put Portugal in front with a sensational goal at the end of the first half.

The late Iran penalty denied the European champions top spot in the group and means they play Uruguay in Sochi in the last 16 on Saturday, rather than Group A runners-up Russia.

What a night for VAR

VAR has been a major talking point in the 2018 World Cup but the final matches in Group B provided its most controversial night so far.

The controversy began with the awarding of Portugal's penalty, which was eventually saved by Iran goalkeeper Ali Beiranvand, diving to his left to deny Ronaldo.

The Real Madrid striker had gone down under the challenge of Iran's Saeid Ezatolahi and, after originally waving away appeals, Enrique Caceres rightly reversed his decision and awarded the spot-kick after checking VAR.

The game became heated after that decision with both sides asking for further reviews, but its next use again involved Ronaldo.

Attempting to get in front of Morteza Pouraliganji, Ronaldo appeared to catch the Iranian in the face with a flailing arm.

After a lengthy stoppage while he watched replays on the VAR pitch-side TV monitor, the referee deemed it only worthy of a yellow card.

But perhaps the most controversial decision came in second-half stoppage-time and resulted in Iran's penalty.

Iran played a deep cross towards Sardar Azmoun and from close range his knock-down hit the outstretched arm of Portugal defender Cedric Soares, who was jumping to head the ball.

Again the referee took his time in making a decision and once again changed his original call, ultimately choosing to award a penalty.

'Shambolic' - what they said about VAR

BBC pundit Alan Shearer described the decision to award Iran's late penalty as "shambolic".

"How on earth can he think that is a penalty?" the former England captain added. "If he thinks it is deliberate handball, he is crazy.

"There is no way on earth that is deliberate handball. It turns the game into an absolute farce."

Iran's Portuguese manager Carlos Queiroz, who managed his country at the 2010 World Cup, suggested the referee chose not to send off Ronaldo because of the forward's high profile.

"In the rules, an elbow is a red card, it doesn't matter if it's Lionel Messi or Ronaldo," he said.

But Portugal manager coach Fernando Santos played down the incident.

"I wasn't concerned [about Ronaldo]," he said.

"It seemed like a normal thing in the match and the referee did what he had to do.

"I think the VAR did its job and that's what we have to accept."

What of the rest of the game?

Portugal had been frustrated for 44 minutes in the first half by a well-organised Iran who also looked dangerous on the break.

But the game's first goal came with a piece of magic from the boot of former Chelsea loanee Quaresma in the 45th minute.

The winger cut in from the right flank, played a one-two with a team-mate, and then curled a right-footed shot from the edge of the penalty area into the far top corner with the outside of his boot.

Play in the second half was repeatedly broken up by fouls, VAR incidents and strong protests in response to tackles from both sides.

Querioz had to be spoken to by the referee both for encroaching on the pitch and for his complaints at the referee's decisions.

Even after Karim Ansarifard had scored Iran's controversial penalty, winger Mehdi Taremi could have won the game with a chance in the fourth minute of stoppage time, but he hit the side-netting with his effort from inside the penalty box.

Aside from his penalty miss, Ronaldo had few chances on goal, with his best effort a shot straight at the Iranian goalkeeper in the third minute.

The blank means he remains on four goals for the tournament, one behind England striker Harry Kane, who leads the race for the Golden Boot.