Real Madrid suffered an almighty fright before a Cristiano Ronaldo hat-trick hauled them back from 2-1 down and gave them a 4-2 win over outsiders Kashima Antlers in the Club World Cup final in Japan.
Two goals from Gaku Shibasaki stunned the European champions as the Japanese champions took a 2-1 lead early in the second half before a Ronaldo penalty brought Real level on the hour.
The 11-times European champions then survived several more scares and a possible sending-off for captain Sergio Ramos before Ronaldo scored twice more in the first period of extra-time.
Real, who won the tournament for the second time in three years and were crowned champions for a fifth time overall, appeared set for an easy victory when Karim Benzema gave them a ninth-minute lead but Shibasaki changed the story by levelling one minute before halftime.
Kashima were the first Asian team to reach the final although they qualified for the tournament as champions of host nation Japan.
Asian champions Jeonbuk Motors had lost in the quarter-finals.
"We knew it was not going to be an easy one. They were very aggressive," Real coach Zinedine Zidane told reporters.
Real went ahead when Luka Modric's volley was parried by Hitoshi Sogahata and Benzema tapped in the rebound.
Kashima refused to be overawed, continued playing their neat football and snatched a shock equaliser just before the break.
Shoma Doi's cross found Shibasaki, whose first touch was poor but he was gifted a second attempt when Raphael Varane failed to clear and he smashed the ball into the net.
Shibasaki struck again six minutes after the break when he collected a poor Real clearance, got away from three opponents and fired a low shot past Keylor Navas from 25 metres.
Real were facing their first defeat since they lost to VfL Wolfsburg in April, a run of 36 competitive games, until Lucas Vazquez was bundled over by Shuto Yamamoto and Ronaldo converted the resulting penalty on the hour.
Kashima continued to give as good as they got and had three good chances in the final minutes of normal time.
Fabricio's goalbound drive was tipped over by Navas and the Costa Rican goalkeeper came to the rescue again one minute later by blocking Mu Kanazaki's shot after he got free of the Real defence.
Yasushi Endo could have won it with the last kick but fired wide at the far post while Sergio Ramos was lucky to escape a second yellow card for a push on an opponent, a decision which Kashima coach Masatada Ishii said "lacked courage".
Ronaldo ended Kashima's dream when he collected Benzema's sliderule pass and fired past Sogahata eight minutes into extra-time, then settled the match six minutes later with an emphatic finish into the roof of the net.
"We gave Real Madrid problems," said Ishii. "That's what we were able to do. But we made small mistakes in positioning and judgment so it's frustrating."