The hosts were roared on by a frenzied crowd on the Gold Coast as they produced a Games-record time of 3:31.04 - touching the wall just 0.09s in front of England.
In a race that went down to the very last stroke, Mitch Larkin - who has now claimed gold in each of his five events at the Commonwealth Games - got Australia off to a flying start as they took an early lead over Canada and England.
However, England's Adam Peaty produced a stunning breaststroke leg to haul his side back in front, recording a time of 57.64s to overtake Jake Packard and give England the advantage at the halfway stage.
It was a lead individual 200m butterfly silver medallist James Guy extended in the third leg as Australia continued to fall behind, with Chad le Clos also dragging South Africa into contention at that stage.
However, an enthralling final lap saw Kyle Chalmers overhaul Ben Proud, who just over an hour before had won gold in the 50m freestyle, touching the wall a fingertip ahead of England to bring the swimming action to an incredible close.
South Africa claimed bronze ahead of Scotland, but it was all about the battle between Australia and England as the host nation produced a fitting finale to a programme which has seen them dominate in the pool.
The men's relay gold came just moments after Australia's 4x100m women's medley team had beaten Canada in another thrilling race, ensuring that the hosts won eight of the nine golds on offer on the final night.
The victories took Australia's final swimming medal tally to 73 over the six days of action, including a whopping 28 golds to catapult them well clear at the top of the overall medal table.