They will now battle the USA for the gold medal at 5am AEST on Monday morning as they seek to replicate their performance from 2006 when they were crowned FIBA World Cup Champions.
After breezing through their first four games of the tournament, the Opals were forced to fight until the final siren against Spain and trailed by eight points at three-quarter time.
Liz Cambage (33 points, 15 rebounds, four blocks) had enjoyed a battle against the Spanish front court (and the crowd) throughout the game but she was determined not to let this one slip, scoring six quick points to open the fourth quarter.
Katie Ebzery drilled a corner three as well to give the Opals a 9-0 run and then Astor Ndour, Spanish starting forward, fouled out.
Cambage flirted with fouling out herself after a technical but Laura Nicholls fouled out instead for Spain only a couple of minutes later and the visitors were in the bonus with the game tied inside the last 3:30.
Cayla George (nine points, 11 rebounds, two assists) then stepped up, scoring five in a row including a big three-pointer from an offensive rebound to gain the ascendancy and Australia picked up their defensive intensity as well with blocks from Cambage and O'Hea.
The two combined again on the following possession with O'Hea (four points, two assists) picking up the steal and Cambage finishing a broken play with a lay-up.
That put the Opals up by five and they staved off a Spanish miracle with more lockdown defence, preventing any late three-point attempts as they finished the game with an 8-1 run and a 22-8 final term.
— FIBA (@FIBA) September 29, 2018
The game did not look like it was headed to a thrilling conclusion after the Opals dominated the first quarter, a trademark of their 2018 FIBA World Cup campaign.
They pushed the pace early, beating Spain in transition even off made baskets and Bec Allen (eight points, two steals) maintained her form from the Quarter-Final with an early three-pointer while Steph Talbot (two points, eight assists) also impressed.
Cambage recorded nine points to quarter-time as well, putting her team up by 15 at one stage before Spain reeled in the deficit with a 9-2 run to ending the opening stanza.
Their defence then tightened up in the second quarter, sending back lay-up attempts by Ebzery (ten points, three assists) and Sami Whitcomb (five points) to hold the Opals scoreless for over four minutes.
Consecutive three-pointers from Alba Torrens then drew Spain level before the home side moved in front right on the half-time buzzer for their first lead of the game.
Ebzery had the response to start the third, scoring the first two baskets including a bail-out shot clock buzzer beater and that sparked an 8-2 run for the Aussies.
Spain were not going away though, answering with an 8-1 run themselves and the crowd was delirious when they went into three-quarter time with an eight-point edge.
Find the box score here.
The Opals will now meet the USA for the first time since the 2014 World Cup Semi-Final when the Americans prevailed by 12 points.
Winners of the past five World Cup's combined, this is the first time Australia and the USA will meet in a FIBA World Cup gold medal game and both teams enter the contest undefeated.
Watch the game live on Fox Sports Australia channel 505 and keep up to date via @basketballaus.
The Chemist Warehouse Australian Opals Schedule for the FIBA Women’s World Cup (times AEST):
September 22: Australia def. Nigeria (86-68)
September 23: Australia def. Argentina (84-43)
September 25: Australia def. Turkey (90-64)
September 28: Quarter-Final- Australia def. China (83-42)
September 30: Semi-Final- Australia def. Spain (72-66)
October 1: Gold Medal Playoff- Australia vs. USA at 5am