NBA champion Marc Gasol saved Spain on Friday as they battled back to beat Australia 95-88 after a second overtime period and reach the Basketball World Cup final.
They will face Argentina in Sunday's decider in Beijing after the South American team beat France.
A thrilling semi-final was 71-71 at the end of regulation time and the two sides could not be separated at the end of a nervy first overtime.
Finally, the 2006 world champions Spain jubilantly emerged after the Boomers appeared to run out of juice.
Sergio Llull hit two three-pointers in the second overtime for Spain to cap their comeback.
Gasol, the Toronto Raptors centre, finished with 33 points, six rebounds and four assists after stepping up late in a breathtaking game when his country needed him most.
"We came back, we stuck together through tough times, that means a lot," said the 34-year-old, a three-time NBA All-Star.
The Spaniard played a key role in the Raptors' historic run to the NBA crown and knows that victory on Sunday will cap the perfect season.
"It's been great, I have been very fortunate," he said.
"I knew that it would not be easy physically (going from the NBA Finals to the World Cup) but it's definitely worth it.
"Not because of the final but passing along those values to the team. It's our turn to pass on the legacy to the next generation (of the Spain team)."
Ricky Rubio was also pivotal once more for Spain with 19 points, 12 assists, seven rebounds and four steals.
Red-hot Patty Mills was unfortunate to be on the losing side, leading Australia with 34 points.
'Hell of a game'
The Australians, who had never gone beyond the quarter-finals in 11 previous World Cups, had the whiff of revenge in their nostrils " and a first final.
Spain edged the Boomers 89-88 in the bronze-medal match at the Rio 2016 Olympics and the Australians had waited three long years to get their own back.
In San Antonio Spurs livewire Mills they had one of the players of the World Cup and his three-pointer midway through the second quarter put Australia 27-22 in front.
The in-form guard pulled off the same trick with 88 seconds left on the clock in the second quarter to give Australia a 37-32 advantage at the break.
But Spain slashed the lead to four points going into the fourth quarter and then just two points with 3:44 left.
Spain were just one point behind with 28 seconds to run and they had the momentum. Gasol, nerves of steel, nailed two free throws to put Spain up 71-70.
Mills then made one free throw with four seconds left but missed the other and the match was level at the end of regulation time.
Despite the crushing disappointment, Australia will need to raise themselves for Sunday's bronze-medal match and this is still their best World Cup performance.
Coach Andrej Lemanis called it "a hell of a game of basketball and fun to be involved with".
"Tough to lose, no doubt, it comes down to a couple of plays here and there," he said.
"At the end of the day, we had chances to win the game, we had every opportunity to win the game."
Argentina outfox France
Argentina are one win away from their first World Cup title since 1950 after they brushed aside France 80-66 in the other semi-final.
Cheered on by a group of fans decked out in their national colours, Argentina made a fast start against France, who had ousted the US in the previous round.
Argentina opened the game up with a 10-2 run that saw Luis Scola, the age-defying 39-year-old, dominate the court.
The South Americans led 39-32 at half-time and were never in serious danger of surrendering their advantage after that.
Scola, the grand old man of basketball, finished with 28 points, 13 rebounds and two assists. He was given a huge ovation when he stepped off the court near the end.
With an average height of 6'8" (203 cm), France are one of the tallest rosters at the 32-team World Cup.