Bolt, who has not lost a global final since he false-started at the 2011 World Championships, was hoping to extend his record-breaking gold medal tally at the World Championships to 12 in his last major event.
With thousands of Jamaican fans in the London Stadium getting ready to celebrate on day two of the championships, the 30-year-old was outrun in the final 30 metres by former Olympic and world champion Gatlin, who grabbed his first world title since 2005 at the age of 35.
Bolt took bronze in 9.95 seconds behind Gatlin (9.92) and American silver medallist Christian Coleman, who clocked 9.94.
Before the race the crowd had booed Gatlin, a pantomime villain in athletics because of a previous ban for drugs, and were subdued for a few minutes at the end of the race before cheering Bolt on his lap of honour.
Bolt has a final chance to win a world medal for Jamaica in the 4x100m later in the championships.
Bolt hugged his American rival on the track afterwards and was gracious in defeat. “Usain said to me: ‘Congratulations, you deserve it,'” Gatlin said. “And that's from the man himself. He knows how hard I work.“
Earlier in the night, Ethiopia’s Olympic champion Almaz Ayana cast aside a season of illness with a commanding piece of front running to win the women’s 10,000m title.
After a slow, tactical start, Ayana burst away from the rest of the field, lapping most of her rivals to finish in 30 minutes, 16.32 seconds.
The winning margin of more than 46 seconds over silver medallist and compatriot Tirunesh Dibaba was by far the biggest in the history of the championships.
The men’s discus witnessed the closest competition in championship history with Lithuania's Andrius Gudzius winning by just two centimetres with 69.21m ahead of Sweden’s silver medallist Daniel Stahl on 69.19m.
After taking the silver at last year’s Rio Olympics, South African Luvo Manyonga grabbed his first senior global title in the men’s long jump, winning with 8.48m to American silver medallist Jarrion Lawson’s 8.44m.