The Australians looked set to level the series after a rousing opening 30 minutes but the Lions roared back with fullback Hugo Keenan scoring with 45 seconds left on the clock for his team to take the lead for the first time in the match.
The game ended in controversial circumstances with the Wallabies flanker Carlo Tizzano appearing to have been illegally cleaned out in the build-up to the match-winning try.
While the TMO and referee Andrea Piardi reviewed the clean-out by Jac Morgan, he didn't deem it a penalty and the try stood.
Coming after the Wallabies loss in Brisbane, the Lions will lift the Tom Richards Cup with a third Test still to play in Sydney.
The result meant the Wallabies became the first team since the 1966 Lions tour to have lost the series in two games, with that Australian outfit losing both matches in a two-Test tour.
In the Lions' last two visits down under, in 2001 and 2013, Melbourne had been a happy hunting ground with the Wallabies drawing level after first Test defeats.
It appeared this series would also follow that script as the home side came out firing in front of a crowd of 90,307, which was the largest ever to watch a Lions series.
With Will Skelton and Rob Valetini, who sat out the first Test through injury, adding size to the pack, the Wallabies answered their critics and aimed up early in a physical display that had the tourists on the back foot.
Two early penalty kicks by Tom Lynagh gave the Wallabies an early six-point lead and a boost of confidence but the Lions were first across the tryline in the 15th minute through hooker Dan Sheehan.
Prop James Slipper, only the second Wallaby to have played in two series then scored for an 11-5 lead and everything seemed to be going the home side's way.
Freeman was yellow-carded after his team's multiple infringements and the Wallabies then raced out a 23-5 lead with halfback Jake Gordon and fullback Tom Wright both scoring.
But the tide started to turn and the Lions closed the gap to 23-17 by halftime, with flanker Tom Curry and centre Huw Jones touching down.
The second half was an arm wrestle and a 59th minute try by Tadgh Beirne set up a thrilling finale.
The Wallabies showed desperation in defence and it looked like they would hold on for a famous victory but the Lions had the final say.