Al Habsi looked to have gifted Reading a point when his terrible error ten minutes from time allowed the visitors to draw level 2-2 when he somehow bundled the ball into his own net.
However, Gomez had the final word two minutes into injury-time to complete the perfect hat-trick having scored with his right foot, head and left foot to give Wigan owner Dave Whelan the perfect birthday present.
After defeats by West Brom and Liverpool, Wigan needed to get back on track and they should have been in front in the 12th minute when Jean Beausejour swung in a lovely cross on to the head of the unmarked Arouna Kone, but he somehow headed wide with Adam Federici beaten.
Wigan were still in the ascendancy, though, and Kone missed another chance in the 24th minute when he tried to walk the ball in but a combination of Federici and Nicky Shorey clearing off the line denied the Ivorian.
And the Reading full-back was the architect when the visitors did take the lead in the 35th minute. Hal Robson-Kanu was felled by James McCarthy again, this time on the left byline, and Shorey’s curling free-kick was powered home by Sean Morrison.
Franco Di Santo came on for Shaun Maloney at half-time and the Argentinian almost scored with his first touch after he was played through by Gomez, but Federici tipped the shot round the post.
Wigan drew level just before the hour mark and Di Santo was again involved, crossing from the left and, although Federici saved Gomez’s first effort, he could not hold it and the Spaniard tucked away the rebound.
Reading were playing on the break now, but they were almost back in front in the 62nd minute when Robson-Kanu crossed and Adam Le Fondre flicked a header towards the corner only for Al Habsi to fling out a hand.
Wigan hit the front in the 68th minute as Beausejour sent in another peach of a cross and Gomez grabbed his second with a textbook diving header.
The most important thing was that Wigan were on course for three points, but that all changed in the 80th minute with one of the most bizarre goals of the season.
Robson-Kanu’s shot spun high up into the air off a Wigan defender but Al Habsi seemed in control as the ball dropped back down. However, a combination of the spin and the wet ball contributed to it slipping through the keeper’s grasp and then hitting the bar before going in off the Oman international.
Wigan grabbed the winner two minutes into injury-time as Gomez drilled in a pull-back from Kone, much to the relief of his goalkeeper.