LONDON — The moment and the crowd of 55,900 at London Stadium were his, and Usain Bolt was inches from a clean getaway.

But on Saturday night, there would be no pitch-perfect ending to what Bolt insisted was the final individual race of his unparalleled career.

The gold medal in the 100 meters at the world track and field championships went instead to Justin Gatlin, the 35-year-old American who has long been Bolt’s foil and who had not won a 100 world title since 2005. Gatlin has served two doping suspensions in his career, and the spectators booed him before the final, just as they had in the early rounds.

Running far outside in Lane 8, Gatlin finished in 9.92 seconds, reeling in Christian Coleman, a 21-year-old countryman he has mentored, with a final surge. Gatlin screamed with delight and put an index finger to his lips as if to silence the crowd when the results of this very close race appeared on the scoreboard.