Wigan held off a late Harlequins fightback to draw closer to their relegation rivals at the foot of Super League with a third straight victory.
Harlequins: (12) 24
Tries: Haumono, Penalty, Mbu, McLinden
Goals: Paul 4
Wigan: (12) 26
Tries: Ashton 2, Dallas, Calderwood
Goals: Dobson 5
Quins went ahead with a Solomon Haumono try but needed a penalty try to level it at the interval after Chris Ashton and Brett Dallas scored for Wigan.
Joe Mbu's score put Quins 18-14 up but Mark Calderwood and Ashton, with his second, put the visitors in command.
But Mark McLinden's late try, converted by Henry Paul, ensured a nervy finish.
Victory lifted Wigan to within two points of Wakefield, who face St Helens on Sunday.
Harlequins, only three points ahead of Wigan, will also be looking nervously over their shoulders.
Wigan coach Brian Noble:
"I am really proud of the team. We have showed today that we can close out the game. We can see a little bit of daylight now but there is still a lot of work to do.
"Three weeks ago it was not looking good. The players will be disappointed with the points that we gave up today but that is a good sign in some ways. It's all on for next week now."
Harlequins coach Tony Rea:
"Penalties and mistakes cost us massively. We were close but not close enough and that is a huge disappointment. There were three breakaway tries that Wigan scored.
"It makes it a bit harder for us to make the top six now. We need to put a little run together, to get some momentum. We haven't really had one of those all season."
Harlequins: Lucky Luisi, Wells, Gafa, Smith, Bradley-Qalilawa, Paul, McLinden, Temata, Randall, Tookey, Haumono, Purdham, Mbu. Replacements: Weisner, Williams, Leuluai, Heckenberg.
Wigan: Ashton, Calderwood, Radlinski, McAvoy, Dallas, Orr, Dobson, Fielden, Higham, Paleaaesina, Hock, Fletcher, O'Loughlin. Replacements: Logan, O'Carroll, Hansen, Tickle.
Referee: K Kirkpatrick
The BBC is not responsible for the content of external internet sites