Spain beat Australia 95-88 in double overtime to claim a place in the Basketball World Cup final in China.
The second-ranked team were on the verge of going out before Australia’s Patty Mills missed one of two free throws with 4.7 seconds of regulation time left to leave the game tied 71-71.
Spain took control in the second of two added periods to reach their first final since their 2006 win.
France take on Argentina in the second semi-final later on Friday.
Spain’s NBA champion Marc Gasol was his team’s top scorer, the Toronto Raptors star hitting 33 points in the comeback victory, while point guard Ricky Rubio contributed 12 assists.
Mills, the San Antonio Spurs point guard, was Australia’s driving force, leading all scorers with 34 points.
He guided his team into an eight-point second-quarter lead, which increased to double figures in the third.
But, with victory within their grasp in the dying seconds, Mills missed once from the free-throw line to allow Spain another shot in overtime, which they took at the second time of asking after the first period ended all square.
With holders USA already knocked out by France, new champions will be crowned in Sunday’s Beijing final.