Valtteri Bottas edged out his Mercedes team-mate Lewis Hamilton and will start on pole for Sunday's Chinese Grand Prix.
Bottas - who currently heads the Drivers' Championship - outpaced Hamilton by just 0.023s in an enthralling qualifying session and recorded a lap time of 1:31.547.
The Finn has held an advantage over Hamilton so far this weekend and he looked in good shape during practice too.
Hamilton - a five-time winner - struggled to get the most out of his car, but Mercedes will be on the first line of the grid in Shanghai on Sunday.
Discussing his lap, Bottas said: "It's been a good weekend so far - I felt really comfortable in the practice, but honestly I struggled in Q3 to get a perfect lap.
"The lap was ok, not completely how I wanted it but it was good enough for pole and the car has been good enough this weekend and Lewis has improved today too.???
Despite his disappointment, Hamilton was delighted for the team.
He said: "I didn't give up, I kept pushing. Valtteri has been stellar all weekend.
" I've been fighting the car but I'm much happier. It was eight tenths at one stage so to be as close as we are at the end is fantastic. It's an incredible result for the team. Ferrari are particularly quick on the straights. It's evident this weekend we've gained some performance through the corners."
Just three tenths of a second separated the Ferraris and the Mercedes.
However, it was a qualifying session to forget for Red Bull, as Max Verstappen failed to get a final run after the chequered flag dropped before he could cross the line.
Red Bull team chief Christian Horner said: "A bit of jockeying position just before the start of the lap.
"Max was in a good position, Seb passed him round the outside so he's hung back and then a Renault has passed him.
"It was a shame because I think we could have made the second row today."