Both teams were desperate for a win to cement their position in the top six in an early finals preview at McKellar Park on Sunday.
Adelaide were already understrength after all-time equal top goal-scorer Fiona Worts left the club for an undisclosed record transfer fee on Thursday.
But the visitors suffered a further blow to their season when Canberra forward Emma Hawkins pressured defender Matilda McNamara to loft a pass towards Melegh.
The teenage goalkeeper couldn't control the ball, which rolled into the bottom left corner in the 69th minute.
Eight minutes later Hawkins landed the knockout blow when Bethany Gordon cut the ball back and found the 24-year-old, who fired it into the top right corner.
Sunday's result means Adelaide (30) sit four points away from ladder leaders Melbourne City (34) with two games remaining.
Without inspirational forward Michelle Heyman because of Matildas duties, Hawkins stepped up for the home side, assisting in the opener, causing Melegh's slip-up, before scoring their third goal.
Victory means Canberra (30 points) leapfrog Adelaide into third position and are in the box seat to make a first finals appearance since 2021 as they lead the seventh-placed Perth by six points.
Gordon drew first blood when she found herself on the receiving end of a sneaky through-ball from Hawkins and poked it through Melegh's legs in the 10th minute.
Canberra continued to sniff at goal, but the visitors equalised when an open Sarah Morgan calmly slotted home.
After piling on the pressure, Canberra took the lead through Melegh's own goal, before Hawkins netted in the 77th minute.
Substitute Sian Dewey set up a thrilling finish when she hit the ball from distance into the bottom left corner in injury time, but the home team held firm.