Spain last won the World Cup –– the country's only title –– in 2006 while Australia has never won the title.
Spain is back in the final of the basketball World Cup with a chance to match the title it won 13 years ago.
Marc Gasol scored 33 points to lead Spain over Australia 95-88 in double overtime. Ricky Rubio scored 19 and Sergio Llull added 17.
It was two 3-point shots by Llull in the second overtime that pushed Spain to one of its largest leads of the game after trailing much of the time.
Patty Mills scored 32 to lead Australia.
Australia will try again for a bronze medal in a major men's basketball championship. The Boomers are 0-4 in third-place games in the Olympics and had never reached the semifinals of the World Cup.
Spain trailed for much of the game but surged in the fourth quarter and took the lead 71-70 when Gasol hit two free throws with 8.7 seconds to play in regulation.
Mills had two free throws to win the game with 4.8 seconds to play, but he missed the second after making the first to send the game into overtime at 71-71.
Both teams had chances to win in regulation and in the first overtime, which ended 80-80.
Spain last won the World Cup — known previously as the World Championship — in 2006 in Japan with players like Rudy Fernandez, Pau Gasol and Marc Gasol. Fernandez and Marc Gasol are still on the team. It was Spain's only title.
Australia has never won the title and never been a medalist.
According to FIBA, it was the seventh game that went into double overtime in World Cup (and its predecessor, the world championship) history. And it was the first to occur in a medal round.
Germany, behind 47 points from Dirk Nowitzki, beat Angola 108-103 in triple overtime in the 2006 world championship. Another five games before Friday went double overtime, most recently Germany's 82-81 win over Serbia in 2010.
It was the first double OT game for either Spain or Australia in any World Cup.
The Wukesong arena in west Beijing, the venue for the finals and semifinals, was built for the 2008 Olympics. Since then it's been rebranded as the Cadillac Arena. The baseball venue for 2008 was nearby but is long gone and replaced by a subway and shopping area.
Up next, Spain is set to face France or Argentina in a championship game Sunday while Australia faces France or Argentina in third-place game Sunday.