However in truth Williams score put the gloss on what was a disappointing afternoon for Wales as they looked to lay down a RBS 6 Nations marker ahead of next year's competition.
Tries from Lachie Turner, Barnes and Will Genia - two of which came when Leigh Halfpenny was in the sin bin - did the damage for the Wallabies, who also beat Wales in the third-place play-off at the World Cup.
Point scorer in chief for Wales was Rhys Priestland, with a try and two conversions but it was Williams' score, despite the result, that brough the house down.
Wales went ahead early on when Aussie skipper James Horwill was penalised and Priestland - who missed the third-place play-off through injury - kicked the three points.
James O'Connor - playing at No. 10 - should have put the Wallabies level just before the half-hour mark but the precocious Aussie pulled his three-pointer wide.
Seconds later with the crowd willing him to cross the line at the other end Williams was needed to foil a Turner try with a last-gasp tackle.
Priestland put Wales six points to the good eight minutes before the break, kicking a relatively unwanted penalty - the home side wanted a longer advantage - after the Wallabies were penalised for offside.
O'Connor had the last laugh in a tepid first half however by making his last kick of the half a penalty to reduce the Wallabies deficit to three points at 6-3.
The game turned on its head ten minutes after the break when Halfpenny was sin-binned for tackling O'Connor without the ball and with the try-line beckoning.
Just minutes later the Wallabies made the most of their numerical advantage when Genia squirmed a way through the Wales defence to touch down.
O'Connor's unmissable extras put Robbie Deans' side ahead, 10-6 and the sin-binning got even more expensive when Turner went over in the corner just before the hour mark.
On 62 minutes Halfpenny's pain on the sideline got even worse when Barnes crossed for Australia's third try and O'Connor converted to make it 24-6.
A Priestland score recovered some pride for Wales before Williams brought about the grandstand finish that the Millenium Stadium faithful craved.