Contesting their first semi-final since winning the tournament in 2006, Spain led by a single point after the first quarter but suffered a shooting slump in the second that enabled the Australians to open up an eight-point lead.
With point guard Patty Mills, who notched a game-high 34 points, slashing to the basket and dictating the tempo, the Australians looked set to make it to the World Cup final for the first time.
Both teams struggled to shoot from distance but Australia's offensive rebounding and accuracy from close range put them in the driving seat for much of the second half.
Things were looking bad for Spain as Australia increased their lead to double digits in the third, but they upped the tempo on defence, finally getting to grips with Mills.
With Rubio threading passes all over the court, Gasol started to chip away at the lead, mixing up post-move scores and long-distance three-point bombs with trips to the free-throw line as Australia's game-plan started to unravel.
With both the United States and Serbia already eliminated, both sides sensed a glorious opportunity and a bruising encounter got even more physical as Spain battled back to force overtime.
The first extra period ended even but as Australia's shooting touch deserted them, Spain finally found their offensive rhythm to pull away in the second and go through to Sunday's final where they will face either Argentina or France.