The Terriers had seemed set for a victory in the second half after a superlative first half at the JJB Stadium.
A single lapse in defence allowed Wigan to take the lead through Simon Haworth after a long ball from Pat McGibbon.
Haworth was lurking when Neil Roberts beat Kevin Gray to the ball on the right and sent in an innocuous looking cross which Haworth turned and lobbed over Margetson who had strayed off his line.
Town were at a loss to explain how the goal had gone but they forged on for the equaliser.
The earlier switch to 4-5-1 had allowed Town to control the midfield and, with Kenny Irons pulling the strings as a spare man, there was ample chance for goals.
Andy Booth could have opened the scoring in the first half when he forced Stewart Kerr into a fingertip save after Thorrington had produced a fine cross following Irons and Mattis' good work in midfield.
The Terriers needed a goal in the second half after Haworth's goal but their plans were thrown into disarray by the 73rd minute dismissal of Danny Schofield after his second bookable offence against Paul Dalglish.
Referee Pugh's decision seemed a little harsh, especially after some of the other incidents that had already gone unpunished, but Schofield was off and Town had to score with just 10 men.
Without the presence of Danny Schofield the Terriers were increasingly reliant on the long ball towards Andy Booth but Wigan defended well and had more than their fair share of luck towards the end.
Read Mel Booth's match report in the Examiner.
Wigan (4-4-2): Kerr, Green, Haworth, Ashcroft, Dinning, Brannan, De Zeeuw, McGibbon, Dalglish (Sharp 73), Kennedy, McCulloch (Roberts 46)
Subs not used: Stillie, Mitchell, Kilford
Booked: Kerr, Kennedy, Dinning
Scorer: Haworth 48
Town (4-5-1): Margetson, Jenkins, Evans, Clarke, Gray, Holland, Mattis, Irons, Thorrington, Schofield, Booth
Subs not used: Digby, Baldry, Moses
Booked: Evans, Schofield
Sent off: Schofield 73 (second bookable offence)
Referee: D Pugh