Real Madrid derailed Spain's World Cup preparations when they poached Julen Lopetegui just two days before the tournament, leading to the coach's sacking, so it was with a certain inevitability that their biggest star put the buffers on what would have been a morale-boosting win against Portugal.

Spain's World Cup hopes had threatened to unravel even before Cristiano Ronaldo scored the first goal of a sensational hat-trick in the fourth minute in Sochi, with Madrid behind the Royal Spanish Football Federation's (RFEF) decision to ruthlessly dismiss Bernabeu-bound head coach Lopetegui.

There were reports of a dressing-room revolt as Spain's stars pleaded with RFEF boss Luis Rubiales to allow Lopetegui a stay of execution.

Determined not to be a doormat for the European kings, Rubiales took the bold decision to pull the trigger having been left angered by the lack of communication regarding the deal. Iconic former defender Fernando Hierro was thrust into the hot seat, as Spanish football played out chaotic scenes reminiscent of France's infamous meltdown in 2010.

And having marred Spain's preparations, Madrid's main man ruined their World Cup opener in Friday's 3-3 Group B classic.

Portugal captain and Madrid superstar Ronaldo, with only three World Cup goals prior to Friday's blockbuster, stole the show with a stunning hat-trick inside a thunderous Fisht Stadium.

Ronaldo had fortune on his side at times. The foul from Nacho Fernandez that led to him opening the scoring from the penalty spot was questionable, and David de Gea's uncharacteristic howler gifted him a second.

But he was, typically, Portugal's driving force, Ronaldo sending shockwaves through Spain and raising further doubts about the effects of Lopetegui's departure.

Spain managed to stem the flow in the second half, quick-fire goals from Diego Costa – who had also drawn the 2010 champions level with a stunning solo goal in the opening 45 minutes – and Nacho's stunner turning the match on its head.

The Spaniards grew in confidence with Isco, Andres Iniesta and Sergio Busquets controlling proceedings and Ronaldo becoming more and more frustrated.

However, Spain never really looked comfortable, even with Ramos and Gerard Pique at the heart of it all.

A late foul on Ronaldo set the scene. Forty-four previous direct free-kick attempts at major tournaments had failed to result in a goal. But, from the moment he stepped up to take the set-piece that would ultimately snatch victory from Spain, the ball seemed destined for the net.

And while Spain still emerged with a share of the spoils, Ronaldo's goal will have done little to heal relations between Madrid and the national team in a tumultuous week for the 2010 world champions.