The 30-year-old Jamaican had been given a scare ahead of his last ever individual major championship appearance, with American Christian Coleman beating him into second place in the semi-finals.
And Bolt was unable to raise his level for the final, finishing third as 35-year-old Gatlin produced a season’s best to claim victory in London.
The result is likely to be a remarkable final victory for Gatlin, who has played second-fiddle to Bolt for much of his career.
The 2004 Olympic Champion has twice been banned from the sport for doping offences, once in 2001 and again in 2006, but has long protested his innocence.
Bolt will now be hoping that the 4x100m relay will give him a chance to bow out with a gold medal around his neck.
Gold - Justin Gatlin 9.92s
Silver - Christian Coleman 9.94s
Bronze - Usain Bolt 9.95s
Fourth - Blake 9.99s
Fifth - Akani Simbine 10.01s
Sixth - Jimmy Vicaut 10.08s
Seventh - Reece Prescod 10.17s
Eighth - Bingtian Su 10.27s