The German defender prodded home in the 89th minute after Aaron Mooy's shot deflected into his path.
Huddersfield boss David Wagner and Leeds counterpart Garry Monk clashed in the aftermath, prompting a mass brawl.
Sub Izzy Brown had put the hosts in front from Tommy Smith's cross, before Chris Wood showed composure to level.
The win lifts the Terriers up to fourth, one point and one place above their promotion rivals with a game in hand.
Town deserved their victory, though the game had looked destined to end level before Hefele's late intervention.
Wagner sprinted down the pitch to join his team's celebrations and, after he bumped into Monk on his way back to his technical area, both teams were involved in a confrontation that culminated in both managers being sent off and three players being booked.
The two teams could yet meet again in the play-offs this season.
Huddersfield manager David Wagner told BBC Radio Leeds:
"The mood is fantastic, everyone has a smile on their face and is happy about this afternoon which we were able to celebrate and enjoy together.
"I think it was a great football match from both sides, very energetic, high speed, and battles all over the grass.
"At the end I think the better team won - we were the team which created more opportunities, which had more chances and better chances as well."
Leeds boss Garry Monk told BBC Radio Leeds:
"I really felt for my players at the end - they didn't deserve that at all, they deserved at least a point today.
"I thought we were very committed, we disrupted them, we followed a good game plan and our display warranted more than what we got.
"It was a bitter pill to swallow, to be honest."
Both managers were sent to the stands as Michael Hefele scored a dramatic late winner to help Huddersfield leapfrog West Yorkshire rivals Leeds.