The 30-year-old Botswanan look well placed coming off the bend in the final but faded to a disappointing sixth place.
Guliyev won in 20.09 seconds, also ruining Wayde van Nierkerk's bid for a rare 200-400 double as the South African took second place, with Jereem Richards of Trinidad and Tobago claiming bronze.
Makwala had been barred from running in Tuesday's 400m final over his favorite distance after contracting a stomach virus that required a 48-hour quarantine period.
It also excluded him from the heats of the 200m, but with public sympathy mounting in favor of the distraught athlete, the IAAF allowed him to compete Wednesday, setting him a qualification time to make the semifinals in a solo time trial.
That feat duly accomplished, Makwala qualified for the final with the third fastest time, but with the fatigue of running an extra race and the weight of expectation on his shoulders, he faltered in the straight as Guliyev powered to victory.
Botswana were going to grant a national holiday of celebration should Makwala have won, but he will head home with his reputation enhanced for the dignity and courage he showed after his heartbreak at missing out on the 400m final.
"It's not a shock," declared Guliyev, who took up Turkish citizenship in 2011 after a dispute with the Azerbaijan federation.
It was Turkey's first ever gold at the championships.
"I wanted to win this year. I believed in myself," he added.
With Usain Bolt opting not to defend his 200m title in his farewell appearance, it was always set to be an open race, with van Nierkerk attempting a double last achieved by American track and field legend Michael Johnson in 1995.
An emotional van Nierkerk, maybe affected by all the controversy surrounding his rival Makwala, summed up his feelings.
"It's been a tough week," he told BBC Sport.
Earlier, Christian Taylor of the United States continued his domination of the men's triple jump by claiming his third world title to add to Olympic gold in 2012 and 2016, while another American athlete, Kori Carter, took the women's 400m hurdles gold.