World champion Lewis Hamilton beat Ferrari's Sebastian Vettel to pole position at the Brazilian Grand Prix.
Hamilton was 0.093 seconds clear of his former title rival after a tight, tense battle, with their team-mates Valtteri Bottas and Kimi Raikkonen next.
Vettel was reprimanded and fined 25,000 euros after failing to follow stewards' instructions at the weighbridge.
Max Verstappen and Daniel Ricciardo's Red Bulls were fifth and sixth, but the Australian has a five-place penalty.
Red mist descends again for Vettel
Vettel said his weighbridge incident had happened because he was eager to get back to the pits.
He had done an exploratory lap on used super-soft tyres and wanted to have the soft tyres he wanted to use for qualifying fitted before any rain fell.
Rain was threatening and he wanted to go out again - and being weighed costs time that might have prevented that.
In addition to his other misdemeanours, he also drove at a steward who was standing in his way preventing him going on the scales until they were ready.
Vettel said: "They shouldn't call us. When the conditions are changing like that, it is unfair. I wanted them to hurry up."
He refused to discuss it further when asked to elaborate in a news conference, saying: "I don't want to talk it through. It's clear what happened. We did qualifying. I think we talk about qualifying."
Ferrari started the session looking to have an edge over Mercedes, but Hamilton prevailed in a difficult session that was affected by light rain at various points during the hour, even if the track was dry at the key moments.
Vettel had been second quickest to Bottas by just 0.049secs in second qualifying despite using the harder 'soft' tyre in search of a strategic advantage in the race.
But when it mattered Hamilton just edged him out for his 10th pole of the season.
- Join Hamilton's title after-party - Brazilian GP preview
- Predict your top three drivers at Interlagos
- Chequered Flag podcast: Lewis Hamilton special
Hamilton v Sirotkin
Hamilton had his own incident in qualifying, when he narrowly avoided a crash with Williams driver Sergey Sirotkin at the start of second qualifying.
The drivers were all preparing for their first flying laps and Hamilton suddenly saw the Russian coming up behind him at much higher speed approaching Turn 12.
Hamilton moved left to try to get out of the way but Sirotkin was already going that way and had to take avoiding action.
But there has been no sign yet of a stewards' investigation and Sirotkin said he had no problem with the incident.
Hamilton said: "Everyone was on an out-lap - me, Sergey and everyone in front of me. And when you are on an out-lap… Valtteri was ahead of me and he was backing off to get his gap so I had to back off.
"I was making sure I had the gap but then all of a sudden I saw a car coming at high speed and I was like: 'Oh my God. Is that someone coming on a lap?' So I went left, but he was going left.
"But he wasn't on a lap, so I don't know what his thinking was. We all know to keep a gap."
A parting gift for long-suffering Ericsson
Behind the big three, Swede Marcus Ericsson took a career-best seventh place - which will become sixth on the grid with Ricciardo's penalty for using too many engine parts - two races before what is likely the end of his F1 career.
Ericsson has been dropped by Sauber for next season and is to race in Indycars in the US, although he will remain the team's reserve driver.
He beat team-mate Charles Leclerc, who is moving to Ferrari to partner Vettel next season in a swap with Raikkonen, by 0.196secs.
Haas driver Romain Grosjean was ninth, with Toro Rosso's Pierre Gasly 10th, benefiting from the latest upgraded Honda engine.
Fernando Alonso's F1 career continues to fade out with a fizzle, McLaren having the slowest car in Brazil and the Spaniard able to put it only 18th.
With team-mate Stoffel Vandoorne last of all, the only car Alonso could beat was the Williams of Lance Stroll.
"The races have been the same from July so there are no surprises," said Alonso. "And in Abu Dhabi it will be my last race, we will put in a lot of emotions and a lot of effort and we will be out in Q1 because there are no miracles from one race to another."
What they said
"That was a tough qualifying session," Hamilton said. "Ferrari have been incredibly quick this weekend.
"We have done a lot of work to make sure the car is in the best way we could. The last lap wasn't that great so I didn't know that I had pole and I was so grateful when I heard I did.
"I lost it in Turn Eight," said Vettel. "I tried. The first sector was so good."
Who will win in Brazil?
Choose your top three drivers from the list below