Kenya's Kelvin Kiptum achieved a course record to win the men’s race on his first attempt.
In the women’s race, Ethiopian-born Dutch runner Sifan Hassan appeared to drop back with cramp early on but came back to win.
Australia’s Madison de Rozario beat Manuela Schar, of Switzerland, in a sprint finish to win the women’s wheelchair race for a second time.
Switzerland’s Marcel Hug beat his own course record to win a fifth men’s wheelchair race.
Britain's Mo Farah finished ninth in what he says will be his last marathon. He told BBC One: "London has been so great to me over the years and I wanted to be here to say thank you to the crowd and the support that was just amazing.
"Training went well, and I was confident and I thought I could do between 2:05 and 2:07 but you never know with the marathon. I gave it my all but my body just wasn't responding and that's when you know when it's time to call it a day.
"Part of me was wanting to cry. The people were amazing, even in the rain to line the streets and that's what this is all about. It's what has kept me going for so long throughout my career. I will miss that feeling, I am emotional today."