With the crowd on their feet for every jump, Barshim delivered the performance they demanded by clearing 2.37 metres on his first attempt before watching on as his rivals failed to match his effort.
Two Russians, who are in Qatar competing as neutral athletes, completed the podium with Mikhail Akimenko taking the silver and Ilya Ivanyuk the bronze.
Barshim becomes the first man to successfully defend the world high jump crown.
Qatar's big night, however, ended on a sour note when technical issues prevented the awarding of the high jump medals and the athletes were left standing at the side of podium as officials scrambled to fix the problems.
In the end, with the stadium having emptied the athletes walked off the stage without a ceremony taking place and Officials later announced that the medal presentation would take place on Saturday.
No athlete at these championships was saddled with higher expectations than Barshim who has been one of high jumping's very best for nearly a decade with a collection of Olympic and world championship medals, including a silver at the 2016 Rio Olympics, to underscore his quality.
Adding to the pressure, Barshim arrived at the world championships still in the final stages of his comeback from last year's ankle surgery.
It has been a race for fitness for the 28-year-old Qatari with an entire nation counting on him to provide a golden climax to an event that has been heavily criticised due to the small crowds.
But after seven days of sparse attendances the people of Qatar showed they do care about the sport, at least when one of their own is in contention, as they filled the air-conditioned Khalifa Stadium.
With the championships set to close on Sunday the home nation finally turned out in force, unrolling a massive flag of their hero in one endzone and generating the buzz and excitement that IAAF officials had been desperate for.
When Barshim sailed over the bar at this first attempt the crowd at the end of the stadium, mostly men in their traditional white robes and gutra head dresses, let out a roar.
There was drama attached to Barshim's victory as the Qatari came dangerously close to going out at 2.33, clearing the height on his last attempt to wild cheers.
Now supercharged by the support, it seemed nothing would keep Barshim from the gold and he cleared 2.35 and 2.37, the best jump this year, at the first time of asking.
When no one could match that effort and the message "World Champion" flashed on the scoreboards the crowd responded with another mighty ovation and cheered on as Barshim wrapped himself in the Qatari flag.