The 21-year-old came off the bench to complete a remarkable comeback for Stuart McCall's side from 2-0 behind.
Eoin Doyle's double gave Hibs control but Jamie Murphy tapped in from close range to cut the hosts' lead before glancing home a leveller with 10 minutes remaining.
Things got worse for Pat Fenlon's side when McHugh converted Henrik Ojamaa's cross two minutes from the end and James McPake was dismissed for a second yellow card during injury time.
McHugh passed up a glorious opportunity to fire Motherwell ahead two minutes after Murphy's leveller and admitted that his late goal helped him avoid the wrath of his team-mates.
"The last two years have been pretty frustrating for me personally, the strikers here have been doing well and I have always said that when I get my chance I will have to take it," McHugh said.
"I am delighted to have got the goal after coming off the bench - hopefully I can push on from here.
"I would have taken a bit of stick from the lads if I didn't score the winner, I'm not really sure what happened - Chris Humphrey fired a great ball across and I've not been able to turn it in from about a yard out."