The GB team, made up of Chijindu Ujah, Adam Gemili, Daniel Talbot and Nethaneel Mitchell-Blake, triumphed in a time of 37.47 seconds, beating Justin Gatlin’s US team by 0.05 seconds.
The four Britons ran the fastest time in the world this year.
“It’s unbelievable, world champions,” Gemili said.
“This is just a dream and it’s a reality tonight.”
In the Jamaican team, sprint superstar Usain Bolt pulled up injured on the final leg of his last competitive race.
Bolt had been hoping to sign off from the sport by leading his country to a fifth successive relay gold, but ended up on the floor with cramp in his left hamstring.
The United States, with individual gold and silver medallists Gatlin and Christian Coleman, had been expected to push the Jamaicans all the way – but were beaten by the British team.
In the women’s 4×100 metres relay, Britain’s Daryll Neita led her team to silver ahead of 2015 champions Jamaica.
The American team, anchored by individual champion Tori Bowie, won the race in a time of 41.82 seconds.
Meanwhile, Sir Mo Farah has missed out on his dream double after finishing second in the 5,000 metres.
The British runner, 34, added a silver to the gold he won in the 10,000 metres at the London Stadium last week.
The four-time Olympic champion was beaten in the shorter distance by Ethiopia’s Muktar Edris in a thrilling final.
Sir Mo had fought desperately to claw back the deficit in the finishing straight but Edris held on to win in 13 minutes and 32.79 seconds.
His British rival finished in 13 minutes 33.22 seconds.
Sir Mo was aiming to retain both world titles which he had won in Beijing two years ago. He had also won both distance events in Moscow in 2013.
The 5,000 metres was Sir Mo’s last track event at a championships before he concentrates on marathon racing.