Media playback is not supported on this device
Real took the lead in the ninth minute through Karim Benzema, but Gaku Shibasaki scored either side of half-time to put Kashima in front.
Ronaldo levelled from the penalty spot on the hour mark after Lucas Vazquez was fouled by Shuto Yamamoto.
The Ballon d'Or winner put his side ahead in extra time after being played through by Benzema, and completed his hat-trick seven minutes later.
Listen: 2016 - the year of Ronaldo?
Victory gave Real their second Club World Cup and extended their unbeaten run to 37 games in all competitions.
It also means nine of the past 10 winners of the competition have come from Europe.
The Champions League winners looked set for a comfortable afternoon when Benzema put them ahead, and they dominated possession in the opening stages.
But Kashima - the first Japanese team to reach a Club World Cup final - impressed in an entertaining game, and Shibasaki took both goals well.
Indeed, after Ronaldo's equalising penalty, Kashima had the better chances late in normal time.
First Keylor Navas saved a long-range strike from Fabricio, then Yasushi Endo shot wide at the back post with the final kick of the 90 minutes. At 3-2 down, Yuma Suzuki hit the bar with a header.
The Japanese side also felt Real captain Sergio Ramos should have been sent off in normal time when he appeared to body-check an opponent when on a yellow card.
Referees used video replays to review several decisions during the competition, but Janny Sikazwe chose not take a second look at this incident.
"The referee lacked courage, which was regrettable," said Kashima coach Masatada Ishii.
Victory for Ronaldo capped an impressive year for the forward, coming six days after he won the Ballon d'Or, awarded to the world's best player.
He scored the winning penalty in Real's Champions League final victory over Atletico Madrid in May, before captaining Portugal to Euro 2016 success in the summer.
His hat-trick in Yokohama was the first in a Club World Cup final, and he is now the joint-top scorer in the competition's history with five goals.
"What a game," said Ronaldo. "We had to suffer, but that's what finals are about. It's a trophy we really wanted to win and we end the year in the best way possible so I'm very happy."
Ronaldo has now won the Club World Cup three times, having done so previously with Manchester United in 2008 and Real in 2014. He was already the only player to win the competition with two different clubs.
Having taken over as Real coach from Rafael Benitez in January, Zinedine Zidane's first year in management has been remarkable.
The Champions League, Uefa Super Cup and Club World Cup have all been won during an unbeaten run stretching back to April.
That adds to the former France international's achievements as a player, when he won the World Cup, European Championship, La Liga, Serie A, Champions League, Intertoto Cup, Intercontinental Cup and Uefa Super Cup.
Zidane's side, whose last defeat was 2-0 to Wolfsburg in the Champions League, lead La Liga by four points.
Match ends, Real Madrid 4, Kashima Antlers 2.
Second Half Extra Time ends, Real Madrid 4, Kashima Antlers 2.
Foul by Nacho (Real Madrid).
Fabrício (Kashima Antlers) wins a free kick on the right wing.
Toni Kroos (Real Madrid) wins a free kick in the defensive half.
Foul by Gaku Shibasaki (Kashima Antlers).
Attempt blocked. Álvaro Morata (Real Madrid) left footed shot from the centre of the box is blocked. Assisted by Mateo Kovacic.
Corner,  Real Madrid. Conceded by Naomichi Ueda.
Attempt blocked. Isco (Real Madrid) right footed shot from outside the box is blocked.
Substitution, Kashima Antlers. Shuhei Akasaki replaces Ryota Nagaki.
Mateo Kovacic (Real Madrid) wins a free kick in the attacking half.
Foul by Gen Shoji (Kashima Antlers).
Substitution, Real Madrid. Álvaro Morata replaces Cristiano Ronaldo.
Offside, Real Madrid. Cristiano Ronaldo tries a through ball, but Karim Benzema is caught offside.
Raphael Varane (Real Madrid) wins a free kick in the defensive half.
Foul by Naomichi Ueda (Kashima Antlers).
Corner,  Kashima Antlers. Conceded by Raphael Varane.
Substitution, Real Madrid. Nacho replaces Sergio Ramos.
Marcelo (Real Madrid) wins a free kick on the left wing.
Foul by Yukitoshi Ito (Kashima Antlers).
Second Half Extra Time begins Real Madrid 4, Kashima Antlers 2.
Substitution, Real Madrid. Mateo Kovacic replaces Luka Modric.
First Half Extra Time ends, Real Madrid 4, Kashima Antlers 2.
Casemiro (Real Madrid) wins a free kick in the defensive half.
Foul by Fabrício (Kashima Antlers).
Attempt blocked. Isco (Real Madrid) right footed shot from the centre of the box is blocked. Assisted by Marcelo.
Goal!  Real Madrid 4, Kashima Antlers 2. Cristiano Ronaldo (Real Madrid) left footed shot from the centre of the box to the top left corner. Assisted by Toni Kroos.
Attempt missed. Toni Kroos (Real Madrid) right footed shot from outside the box misses to the left.
Karim Benzema (Real Madrid) wins a free kick in the defensive half.
Foul by Gen Shoji (Kashima Antlers).
Substitution, Kashima Antlers. Yukitoshi Ito replaces Yasushi Endo.
Daniel Carvajal (Real Madrid) is shown the yellow card for a bad foul.
Foul by Daniel Carvajal (Real Madrid).
Yuma Suzuki (Kashima Antlers) wins a free kick in the attacking half.
Yuma Suzuki (Kashima Antlers) hits the bar with a header from very close range. Assisted by Gaku Shibasaki with a cross following a set piece situation.
Casemiro (Real Madrid) is shown the yellow card for a bad foul.
Foul by Casemiro (Real Madrid).
Mu Kanazaki (Kashima Antlers) wins a free kick on the left wing.
Daniel Carvajal (Real Madrid) wins a free kick in the defensive half.
Foul by Yuma Suzuki (Kashima Antlers).
Cristiano Ronaldo scored a hat-trick as Real Madrid survived a scare to beat Japanese side Kashima Antlers in extra time and win the Club World Cup.