Hassan pulled away from Alemu Megertu and reigning Olympic champion Peres Jepchirchir in a sprint finish along The Mall, coming home in 2:18:33.
“I never thought I would finish a marathon and here I am winning it,” said Hassan. “I had a problem with my hip, which made me stop. But it started to feel a little bit better. And then I missed one of the drinks stations! I didn’t practice that part of the race because I have been fasting and so that was quite difficult.”
Earlier, women’s world record holder Brigid Kosgei was forced to pull out less than four minutes after the start.
The Kenyan runner came into the race with injury concerns and looked in visible discomfort early on.
Kosgei, who holds the women’s record of 2:14:04 limped to the sidewalk after around 3 minutes. She then bent down to untie the laces on her running shoes and signalled that her race was over.
In the men’s race, Kelvin Kiptum collapsed to the ground after winning and recording the second fastest time in history over the distance.
The 23-year-old Kenyan runner set the course record with a time of 2 hours, 1 minute, 25 seconds and just missed out on Eliud Kipchoge’s world record by 16 seconds.
“I am so happy with the result,” said Kiptum. “I don’t know what to say right now, I am just grateful. The course felt good, there was a bit of rain around halfway but it was OK.
“I enjoy doing the marathons, it is good preparation for me. I loved it, I am very happy.”
In what was long distance great Mo Farah’s final marathon, defending champion Amos Kipruto and world champion Tamirat Tola were also among the elite men’s field that Kiptum left behind.
Farah, 40, finished ninth with a time of 2:10:28.
The marathon returned to its traditional April slot after three years of being staged in October due to the COVID-19 pandemic.
A record 48,000 people were expected to cross the finish line near Buckingham Palace from a field of 49,675 runners who registered for the race.
The number of entrants was up from the previous record of 43,199 in 2019.
London Marathon organisers said they expanded numbers in an attempt to reach a cap of 50,000.
Runners set off beneath overcast skies amid temperatures of around 8 degrees celsius.
Forecasters had warned there was likely to be heavier rain later in the day.
Marcel Hug won the men’s wheelchair race for the third time in a row, achieving the feat just six days after winning the Boston Marathon.
The Swiss racer won for the fifth time in London and beat his own course record with a time of 1:23:44.
Australia’s Madison de Rozario won her second women’s wheelchair race in a time 1:38:51.