Among the runners were club athletes, members of Parliament and television stars. Many dressed in costume — including giraffes, bells, cars and even Big Ben — for charity. The organizers said a record 1 billion pounds, or about $1.3 billion, had been raised.

The race took runners on a route along the River Thames and through areas such as Greenwich and the Isle of Dogs, past landmarks including the Tower of London and Buckingham Palace, with the finish line on the Mall, near St. James’s Park.

Kipchoge told BBC Sport: “I’m happy to win on the streets of London for the fourth time and to make history. The crowd in London is wonderful, and that spirit pushed me.”

Kosgei told the broadcaster that she was delighted to have smashed her personal best in winning the race. “I am over the moon with that,” she said. “I always promise myself in the last mile that I would never run another step. But this is not my retirement.”

In the prelude to the marathon, observers had wondered how Farah’s feud with a former world-class long-distance runner, Haile Gebrselassie of Ethiopia, would affect his performance. The dispute spilled into the open this past week, when Farah revealed he had recently been the victim of a theft in a hotel that Gebrselassie, 46, owns outside Addis Ababa, the Ethiopian capital.

Farah had spent the past few months training there, and he accused the Ethiopian, once regarded as the world’s greatest distance runner, of ignoring his requests for aid.

The British athlete said the dispute had not distracted him at all.

“It’s all about London Marathon,” he said. “I didn’t mean to take any limelight away from the sport, but at the same time I just put my head down and did what I needed to do.”