On Monday, Makhloufi was told his Olympics were over after he was informed of his disqualification for the highly unusual offence of not trying hard enough in his heat for the 800m.
But he was swiftly reinstated after the emergence of medical evidence which allowed him to run in the 1500m, and he took full advantage of his reprieve to produce a decisive kick on the last lap to win in 3min 34.08sec.
American Leonel Manzano claimed silver in 3:34.79, with Morocco’s Abdalaati Iguider taking bronze in 3:35.13.
Defending champion Asbel Kiprop and world silver medallist Silas Kiplagat, both of Kenya, finished well off the pace in 12th and seventh respectively.
It was a remarkable result for the 24-year-old Makhloufi, who has shown incredible progress this year to drop from 1:46.32 to 1:43.88 in the 800m and slice more than two seconds off his best for the 1500m.
Having qualified for the 1500m final, the Algerian ran in heat five of the first round of the 800m on Monday morning but failed to finish.
“I’m very, very happy with to win,” said Makhloufi, with his left knee strapped following what he said had been a ligament ninjury.
“It’s not easy to win with big athletes in athletics, Kiprop and Kenyan athletes. It’s not easy.”
Makhloufi said he had not felt any pressure during Monday’s deliberations over his fate following the 800m heat.
“It was normal. I wasn’t worried about anything. I continued my recovery with massage,” he said.
Athletics’ world governing body, the IAAF, released a statement saying “the referee considered that he had not provided a bona fide effort and decided to exclude him from participation in all further events in the competition”.
But Olympics organisers later said that the disqualification had been revoked, citing medical evidence, clearing the way for Makhloufi to race in the 1500m.
The Algerian was patient through the first three laps of the race, content to be strung along on the coattails of Nixon Chepseba of Kenya.
With 300 metres to go, however, the Algerian came up with a huge kick to immediately open up a sizeable gap between him and the chasing pack.
As he hit the home stretch, he was so far clear that he even eased up with 15 metres to go before crossing for line for a perfectly judged victory, the second in the event for Algeria after Noureddine Morceli’s gold in the 1996 Atlanta Games.
Manzano’s final sprint nailed a second silver in the middle distance events for the United States at these Games after Galen Rupp’s silver in the 10,000m.
He outstripped Chepseba and Ethiopian Mekonnen Gebremehdin in a thrilling finish that saw him hold off a last-gasp surge from Iguider, who claimed bronze in a close finish ahead of the chasing pack.
“It was the toughest mentally, physically demanding race. I knew I had done the work,” said Manzano.
“There were a couple of moments when I didn’t know if I was still in it or not.
“I’ve been training to the best of my ability, it was an amazing time. It was the only time I’ve ever cried after a race.”