Lewis Hamilton won a thrilling battle for pole position at the British Grand Prix, snatching top spot from title rival Sebastian Vettel on his last lap.
The Mercedes driver trailed Vettel by 0.057 seconds after the first top-10 shootout runs at sunny Silverstone but saved his best for last.
Hamilton improved by 0.1secs on his final lap, showing massive commitment through the super-fast corners.
And with Vettel failing to improve, the world champion took pole by 0.044secs.
The crowd chanted Hamilton's name as he did his interview immediately after qualifying, and he sounded overcome with emotion as he recalled his record sixth pole position at the British Grand Prix.
"I gave it everything I could," he said. "It was so close. The Ferraris pulled something out and I was just praying I could do it for you guys."
Vettel, struggling with a pain in his neck, said: "I was down a bit on the straights. It was so close. Happy with second, it gives us chances in the race."
He added that his neck had been "fine" in qualifying and he was "not worried" about the race, because "you go a bit slower than in qualifying".
Vettel came close to being beaten by his team-mate Kimi Raikkonen, who set the fastest first sector on his final lap but ended up just 0.054secs off the lead Ferrari.
Hamilton's team-mate Valtteri Bottas took fourth, 0.325secs off the pace, ahead of the Red Bulls of Max Verstappen and Daniel Ricciardo.
Ferrari makes Mercedes work for it
Mercedes had been expected to dominate at Silverstone, a track where Hamilton has won for the last four years and which tends to suit the characteristics of their car.
But Ferrari have been strong from the start of the weekend, helped by an upgraded floor on the car aimed at improving its aerodynamic downforce.
Vettel missed the end of final practice because of a crick in the neck, and needed to spend time with his physio before qualifying.
He was still in discomfort but it was not showing in the car, as he set the pace in first qualifying, was just behind Hamilton in the second session and pulled out a blistering lap a the start of Q3.
But Hamilton saved his best until last.
He said he did not know where he had gained the time, "maybe Turn 13," he said, indicating the critical second right-hander in the sweeping Becketts section, which defines speed on to the long Hangar Straight. And the middle sector, where Becketts sits, was where he was fastest of all, while Raikkonen was quickest in the first and last sectors.
"It is such a tricky circuit to position the car in the right places," Hamilton said, "It took everything for me to get it. The fans were there and I could see them and I really wanted to get it, and maybe even give a boost to England. They won't be watching, obviously, because they're playing, but you know what I mean start it off.
"Ferrari have picked up the pace this weekend but I am in the best place I can be and I am excited for a close grand prix tomorrow."
Although Hamilton improved in the first sector on his final lap, Raikkonen was actually fastest both there and in the final sector. But Hamilton's pace in the fast corners of Copse and Becketts was critical.
Hamilton's pole was a record sixth at the British Grand Prix, beating the record he shared with 1960s legend and two-time champion Jim Clark. And now he has his sights set on another record in the race - victory would be his sixth, moving him one clear of the win record for this race he shares with Clark and four-time champion Alain Prost.
Leclerc stars again
Behind the big three teams, Haas were again best of the rest, with Kevin Magnussen pipping team-mate Romain Grosjean.
They were ahead of another starring performance from Sauber's Charles Leclerc in ninth. The 20-year-old Monegasque continues to prove why Ferrari have decided to promote him alongside Vettel for 2019.
Force India's Esteban Ocon was 10th, ahead of the Renault of Nico Hulkenberg.
It was a dire weekend for Williams at their home race, with Sergey Sirotkin and Lance Stroll ending up 18th and 19th, ahead only of Toro Rosso's Brendon Hartley, who did not take part in qualifying after a crash in final practice.
Williams were always expecting a difficult weekend, because the nature of the Silverstone track exposes the aerodynamic weaknesses of their car.
But even they probably did not expect qualifying to go as badly as it did.
Stroll spun off into the gravel on his first flying lap, losing the rear braking into the Brooklands corner, Turn Five.
That brought out the red flag, and as soon as the session re-started, Sirotkin also spun off, this time on entry to Stowe corner. The Russian managed to recover the car from the gravel but was slowest of all.
For McLaren, another great British team in difficult times, Fernando Alonso was in a now-familiar 13th place, while team-mate Stoffel Vandoorne was struggling in 17th, 0.9secs off the Spaniard, perhaps affected by losing a part of his floor after taking a kerb too aggressively.