Asha Philip, Desiree Henry, Dina Asher-Smith and Daryll Neita ran a British record of 41.77 seconds in Rio's Olympic Stadium.
The US, who only qualified for Friday's final at the second attempt after dropping their baton, won in 41.01, the second-fastest time in history.
Silver medallists Jamaica ran 41.36.
Jamaica's Elaine Thompson narrowly missed out on matching compatriot Usain Bolt's sprint treble after her victories in the 100m and 200m.
"Wonderful experience. My first Olympics. Two golds, a silver, I can't complain," she said.
GB's first medal in the event since winning bronze at Moscow 1984 capped a remarkable reversal in fortunes after they failed to reach the final at London 2012.
Philip, the oldest member of the quartet at 25, said: "We came here to get a medal and we delivered. We had a lot of pressure to get this, but we had so much trust and faith in these girls."
Henry, 20, said: "I cannot believe it. This was my first Olympics and I wanted to go out and enjoy it but also to get a medal. To do it I had tears in my eyes. Thank you to everyone who has made this happen."
Asher-Smith, also 20, said: "We have worked unbelievably hard. Out of all the teams I think we worked the hardest. This is for the entire nation."
Daryll Nieta, 19, said: "I am speechless. I am so proud of our team. We absolutely smashed it."
Find out how to get into athletics with our special guide.
Chief sports writer Tom Fordyce
Fabulous from the GB quartet. Having spent the day with them as they trained at Loughborough, there was no missing that this is the tightest of teams - true friends, proper racers. Philip in the mother role, Asher-Smith as head girl, Henry the loud one, Neita the kid. Together history makers.
Tianna Bartoletta, Allyson Felix, English Gardner and Tori Bowie were allowed to compete in the final after running again - on their own - following Thursday's semi-final.
The baton was accidentally knocked out of Felix's hand by Brazil's Kauiza Venancio as she prepared to hand over to Gardner for the third leg.
The US successfully appealed, and ran only two tenths of a second short of the world record at the second attempt.
Bartoletta and Felix were part of the US team that clocked 40.82 to win at London 2012, and Felix has become the first woman to collect five athletics gold medals.
"It's very special. It was great to join these women tonight. It's just a very unique experience," Felix said of her milestone.
Subscribe to the BBC Sport newsletter to get our pick of news, features and video sent to your inbox.

The Bob Smith Spring Cup meeting at Scarborough was abandoned following the Manx soldier's accident on Sunday.
A spokesman for the event said the 25-year-old was taken to Middlesbrough Hospital where he is "undergoing treatment for his injuries".
He added that he is "breathing on his own and his condition is improving".
Redmayne won the Junior Manx Grand Prix last year and is regarded as one of the brightest prospects in the sport.
His crash came after the feature Spring Cup race had been restarted when Northern Ireland's TT star  suffering a leg injury.
Johnston was also taken to hospital for X-rays following the incident.
The organisers were forced to abandon the meeting in North Yorkshire because of a lack of medical cover at the course following the crashes.
The feature race will now be held at the Cock of the North Road Races in June.
Great Britain won an Olympic medal in the women's 4x100m relay for the first time since 1984, claiming bronze as the United States retained their title.
[NEXT_CONCEPT]
Isle of Man rider Billy Redmayne has suffered serious injuries in a crash at the Oliver's Mount Spring Cup meeting in England.