Olivia Price, 20, slipped from the back during a tacking manoeuvre in winds up to 27 knots during the third of five head-to-head races with the Spanish, costing Nina Curtis and Lucinda Whitty valuable minutes as they hauled her back on board.
In any other Olympic class, Australia's mishap would have meant a capsize but the heavy 6-metre Elliot keelboat stayed upright.
The 2011 European Champions, of Tamara Echegoyen Dominguez, Sofia Toro Prieto Puga and Angela Pumariega Menendez won the deciding fifth race for Spain by a clear 100 metres for a gripping 3-2 finale to the Olympic sailing championship.
The Spaniards came into the tournament unheralded but finished third in the qualifying round robin series winning their semi-final against the Russians on Friday.
The 28-year-old Echegoyen Dominguez had predicted a tough five race tussle with the Australians.
"I think all the races will be close," she said. Explaining her success against more experienced teams, she said: "I think the secret is that we have sailed with great concentration and calm and I think the favourites have the pressure."
Their coach Toni Otero told his team to "treat it as a training day" as they prepared for the fifth race.
They led throughout the decider to bring home Spain's second sailing gold. Their first came in the women's Windsurfing RS:X class earlier in the week.
The women's match racing started 14 days ago in the only event in which each nation raced against the other in a round robin series to decide the top eight qualifying boats for the knockout final rounds.
Twelve countries took part in the 66 match series with Australia winning all 11 of its opening matches.
The women's Elliott 6m high-performance keelboat was making its last appearance as an Olympic class. The women will take up the 49er FX a comparable boat to the men's 49er at the Rio Olympics.