The 47-year-old Frenchman trailed Ogier by almost half a minute heading into the penultimate speed test of the four-day event in the French Alps.
But when Ogier limped to the finish with a front left puncture, Loeb reclaimed a lead he had conceded to his compatriot on Saturday. He stayed calm through the final test to seal his eighth Monte-Carlo success in a Ford Puma by 10.5sec.
Loeb, starting his first WRC event for more than a year, was competing for the British M-Sport Ford squad in a one-off appearance. He joins Ogier at the top of the Monte-Carlo roll of honour with eight wins.
His victory means he has topped the WRC podium in three different decades. Co-driver Isabelle Galmiche, a 50-year-old schoolteacher who was making her first top-tier start, became the first female winner of a WRC fixture since 1997.
“I didn’t expect so much when I came here,” Loeb admitted. “It was a great fight, Ogier was really fast and I struggled a bit yesterday and even this morning.”
The duel between the most successful drivers in the sport’s history proved a fitting start to the new hybrid-powered era in the championship’s 50th season.
Ogier led initially after Thursday’s short opening night in his Toyota GR Yaris but a run of four consecutive fastest times on Friday put Loeb ahead. He failed to find the same pace on Saturday and Ogier moved back in front before Sunday’s breathtaking finale.
Craig Breen finished almost 90sec further back in third in another Puma, giving the British-based M-Sport Ford squad an early lead in the manufacturers’ championship.
Kalle Rovanperä languished outside the top 10 after the opening night, but after set-up changes improved the balance of his GR Yaris, he soared up the order to secure fourth.
Despite losing time with engine issues on Saturday, Gus Greensmith claimed fifth in another Puma after winning his first special stage at WRC level. Thierry Neuville was sixth in a Hyundai i20 N after a lacklustre weekend for the Korean manufacturer.
The Belgian fought problems all rally, including a broken damper which punched through his bonnet on Saturday. Team-mates Ott Tänak and Oliver Solberg both retired.
Elfyn Evans, championship runner-up in 2021, was on the edge of the fight for victory until he beached his GR Yaris on a bank and remained stranded there for 20 minutes. The Welshman ended 21st.
WRC2 winner Andreas Mikkelsen finished seventh ahead of Takamoto Katsuta, who regained ground after slipping into a ditch on Saturday. WRC2 podium finishers Erik Cais and Nikolay Gryazin completed the leaderboard.
The championship switches to Scandinavia next month for the only pure winter round of the season. Rally Sweden takes place in Umeå on 24 - 27 February.