The 35-year-old struggled with the pace, the heat and mix-ups over water bottles, but he still beat Steve Jones’s 33-year-old mark with a time of two hours six minutes and 21 seconds.
Farah, the multiple Olympic and world gold medallist who turned his back on the track last year to concentrate on road racing, briefly threatened a shock victory in his first serious attempt around the streets of the capital.
But having appeared on the shoulders of Eliud Kipchoge and Tola Shura Kitata around the 16-mile mark, Farah quickly dropped off the pace.
Kenyan Kipchoge, who won the race in 2015 and 2016, eventually broke 21-year-old Ethiopian Kitata with three miles to go to make it a hat-trick of wins. An exhausted Farah, who finished just over two minutes behind Kipchoge, admitted: “The pace was fast, I was surprised.
“I just had to go with it and see what happened, and if you’re gonna die you’re gonna die.
“Eliud makes it look so easy. I was knackered at 30 kilometres and he just stepped up another gear.
“But to finish third with a personal best, a British record, on the podium, I can’t do any better than that.
“The crowd really got behind me, it was an amazing atmosphere. I really enjoyed it – even though over the last 10km I was b*********.”
It was the hottest London Marathon on record with the temperature reaching 23 degrees Celsius – although it was estimated to be even hotter on the tarmac.
So Farah’s irritation at not being able to find the right water bottle at two drinks stations early in the race was understandable. At one point he was even seen remonstrating with the motorcyclists travelling alongside the runners.
“The drink station was confusing,” he added. “The staff were helpful at the end but at the beginning they were trying to take a picture rather than giving me the drink.
“I was saying to the people on motorbikes to tell the staff to be a bit helpful. I wasn’t wasting energy, I just needed a drink. I had to get it right.”
Welshman Jones, who won the London Marathon in 1985, set his British record time of 2:07.13 in Chicago the same year.
Meanwhile, Paula Radcliffe’s world record survived as Vivian Cheruiyot timed her run to perfection to win the women’s race.
Cheruiyot, 34, took advantage of failed attempts by last year’s winner Mary Keitany and runner-up Tirunesh Dibaba to break Radcliffe’s 15-year-old mark.
Once again the conditions told as first Dibaba, of Ethiopia, and then Cheruiyot’s fellow Kenyan Keitany fell away allowing the 2016 Olympic 5,000 metres gold medallist to claim victory.
Lily Partridge was the first British woman over the line in eighth place.
The 27-year-old said: “It is unbelievable. I felt absolutely fantastic until 35km and then it started to bite. And then it got slowly worse.”
Great Britain’s David Weir won the men’s wheelchair race for an unprecedented eighth time.
In a carbon-copy of last year’s sprint finish the 38-year-old pipped Switzerland’s Marcel Hug into second place.
“The end was tougher than last year,” said Weir. “Mentally and physically, I felt better coming into this.
“The older I get, my endurance is getting better. At the beginning when I used to do marathons my endurance was rubbish, so I’m keeping the speed and gaining a bit more endurance base. I feel a lot stronger.”
Afterwards it emerged Farah had shaved 11 seconds off his own new British record without running a step after a bizarre timing error.
Television viewers were left confused after Farah crossed the line in third place with the clock clearly showing a time of two hours six minutes and 21 seconds.
Yet when the official timings were published Farah was clocked at 2:06.32.
Winner Eliud Kipchoge and runner-up Tola Shura Kitata were also wrongly classified with 10 or 11 seconds added to their times. Marathon organisers eventually announced that a “clerical error” was to blame.