McIlroy looked set for his first professional win on home Northern Irish soil when he led by two shots with four holes to play at Royal County Down.
But the Dane had other ideas as he played the back nine in five under par to finish on nine under for the tournament.
McIlroy, by contrast, crucially bogeyed the 17th and then missed an eagle putt on the 18th which would have forced a play-off.
It was another tale of what might have been for the world number three, who missed out on a first major since 2014 when he bogeyed three of the last four holes in the US Open in June.
"Unfortunately I'm getting used to it this year," said McIlroy.
"Hopefully the tide is going to turn pretty soon, and I can turn all these close calls into victories."
McIlroy took a one-shot lead into the final round and made the ideal start with birdies on the first and second.
With playing partner Matteo Manassero then dropping shots on the third and fourth, McIlroy briefly enjoyed a four-shot lead.
Hojgaard kickstarted his challenge with an outrageous chip-in for birdie on the 10th. McIlroy's advantage was wiped out as he bogeyed the 15th and Hojgaard birdied the 16th.
The world number 88 then dramatically holed out from a greenside bunker at the 17th and completed his magical finish with another birdie at the par-five 18th.
"I had a number today that I was trying to reach, and that was eight (under)," Hojgaard said after securing his fifth DP World Tour title.
"Obviously coming in and finishing on nine was gold and I'm so happy. The game's been trending for a while now and to get this one is massive."
Manassero finished third on seven under, while Englishman Daniel Brown followed up his fine showing at the British Open with fourth after a fourth round 66.