Great Britain reached the Davis Cup Finals last eight in remarkable fashion as Dan Evans and Neal Skupski saved four match points before winning a nerve-wracking decider against France.
In front of a partisan British crowd in Manchester, Evans and Skupski beat Nicolas Mahut and Edouard Roger-Vasselin 1-6 7-6 (7-4) 7-6 (8-6).
Evans won from a set and a break down in the singles but Cameron Norrie lost.
Evans and Skupski, roared on by the home fans, recovered to seal victory.
"It was bonkers. I don't know what we've all sat through for nine hours," British captain Leon Smith said.
Great Britain will now go on to the knockout phase of the men's team competition - known as the Final Eight - in Spanish city Malaga in November.
Four nations - Britain, Australia, France and Switzerland - played in the round-robin event at Manchester's AO Arena, with the top two countries going through.
Britain, who last won the Davis Cup in 2015, finished as Group B winners and will play Serbia or Italy when the draw is made on Tuesday.
Australia progressed as runners-up, with defending champions Canada, the Czech Republic, Finland and the Netherlands completing the line-up.
But notable absences will be hosts Spain, who failed to make it out of Group C, and 32-time champions the United States, who were stunned by Finland in their final Group D tie.
'No panic' for Evans and Skupski in nerve-wracking finale
With Australia already qualified and Switzerland eliminated, Britain knew nothing other than a victory in the best-of-three tie against France would enable them to progress.
What few of the 13,000 crowd - a record for a Davis Cup tie in the UK - would have predicted was the dramatic manner in which their goal was finally achieved.
Evans, 33, laid the platform for the win when he fought back to beat French teenager Arthur Fils 3-6 6-3 6-4.
British number one Norrie, 28, could not get his side over the line as he lost 7-6 (7-5) 3-6 7-5 to Ugo Humbert, teeing up the winner-takes-all doubles match.
Evans and Skupski, who have become Smith's first-choice doubles pair, recovered from a strong start by their experienced rivals before growing in confidence as the boisterous home fans lifted their spirits.
Despite being unable to make a dent on the French pair's serve in the opening two sets, Evans and Skupski went up a gear in the tie-break to level the match.
A nail-biting deciding set also remained on serve - but only after Evans recovered from a double fault which brought up three match points at 5-4.
Evans found a first serve to save one as Roger-Vasselin hit a forehand into the net, boldly watched another return go just long on the second and then saw another forehand from the Frenchman went wide on the third.
The British pair saved another match point on Skupski's serve at 6-5 before converting their second opportunity in the deciding tie-break.
"There was no panic," said 33-year-old Skupski, who is the world doubles number three and this year's Wimbledon champion.
"We just went to the next point. I knew if we got through that game somehow the momentum was going to swing our way."
When Britain sealed victory at almost 22:00 BST, Skupski knelt down and roared after watching a French return fly long while Evans fell on to his back in disbelief.
The pair were quickly mobbed by their team-mates and support staff, including a union jack bucket-hat-wearing Andy Murray.
"The singles is the singles and I feel comfortable on that court, but the doubles was chaos," said Evans.
"I just kept saying to Neal 'we've got a chance, we've got a chance' and we both kept going. We stuck together.
"It's emotional. You want to be with these guys in the finals. It's an immensely proud moment for me and the team."
Inspired Evans thrives in Davis Cup atmosphere
With a strong squad at his disposal, Great Britain captain Smith had a tough selection call to make for the win-or-bust tie against a talented French squad.
Ultimately, he picked his highest-ranked players in Evans and Norrie, with former world number one Murray and promising youngster Jack Draper missing out.
The move also ensured Evans - who would have played second if the lower-ranked Murray or Draper had been selected - could have a break before what turned out to be the decisive doubles.
The world number 27 was particularly inspired all week in Manchester, thriving in the partisan atmosphere of the team event and winning both of his singles matches.
"Davis Cup is why I played tennis at the start," said Evans, who comes from the West Midlands.
"I remember watching the Birmingham ties, finishing late on a Sunday night. That was my first introduction to professional tennis really.
"That was the be-all and end-all to play Davis Cup for my country - and it still is. I'm not a nervous person but before you play Davis Cup it is a different feeling."
What's next in the Post Office Horizon scandal? Nick Wallis continues his investigation into the widest miscarriage of justice in UK legal history
The batsman who changed the face of cricket: How wearing a helmet revolutionised the safety of the sport