ZURICH — Four-time Olympic champion Mo Farah’s track career ended with a thrilling win in a sprawling four-man finish to the 5,000 meters at the Weltklasse Diamond League meeting Thursday.

Farah avenged his world championships loss by Muktar Edris, who fell over the finish line; just 0.13 seconds separated the first four men. They also shared the top four places in London two weeks ago.

Britain’s Farah doggedly held his lead and finished in 13 minutes, 6.05 seconds, 0.04 ahead of Paul Chelimo of the United States and Edris. Chelimo was later disqualified for pushing Farah and Edris across the line.

Edris was already stumbling when Chelimo nudged him from his left side, forcing him to bring down his Ethiopia teammate, Yomif Kejelcha, who was upgraded from fourth to third.

“Oh man, I had to fight the last 200 meters there. I managed to hold them,” Farah said in a television interview. The 34-year-old runner will switch to road races.

Ben True of North Yarmouth finished eighth in 13:17.62.