The Owls had to come from behind after Mark Carrington put the Dons ahead in the sixth minute, finishing well with a first-time shot into the bottom corner from the edge of the area.
But Wednesday drew level when a hanging cross by Chris Sedgwick was headed in by Mellor.
Five minutes later the game was turned on its head when the unfortunate Luke Chadwick diverted Mellor's cut-back into his own net.
Mellor claimed his second in the 71st minute when he nodded in unmarked from Gary Teale's cross, and he completed his treble with a glancing header from Tommy Spurr's corner with seven minutes to go.
Source: PA
Source: PA