Defending world champion Fernando Alonso edged McLaren teammate Lewis Hamilton to take the pole position for the Hungarian Grand Prix.
Alonso timed 1 minute, 19.674 seconds on the 4.381km Hungaroring circuit with Hamilton at 1 minute 19.781 seconds.
It was the 17th career pole for Alonso but only the second of the season. The other one was at Monaco, a race he won.
Nick Heidfeld of BMW-Sauber was third and Kimi Raikkonen of Ferrari was fourth.
"I think we have been very competitive all weekend from the first session to qualifying," Alonso said. "The last two grand prix we didn't have a chance to beat Ferrari under dry conditions and I think we can do it here."
Hamilton said a delay in the pits cost him a chance to make another attempt at beating Alonso's time.
"It is just good to be back here and on the top and get through qualifying. We had a hard weekend last race," Hamilton said.
The rookie, who leads the overall season standings, crashed in qualifying at the European Grand Prix and came in ninth after nine podium finishes in a row.
Ferrari's Felipe Massa, who has had four pole positions this season and the fastest time in Saturday morning's practice, was just 14th with 1 minute 21.021 seconds. His team had to scramble and push his car back to the garage before his final run after Massa stopped in the pit lane.
Massa timed 1 minute 20.183 seconds about three hours earlier to lead Alonso in practice. At the opening race of the season Massa started 16th and came in third before winning two of the next three races.
Last year's winner here, Jenson Button of Honda, failed to make it past the first portion of the three-tiered qualifying session. He was 17th and the slowest six are dropped after the first 15 minutes.
Ferrari and McLaren have won all 10 races this season, with Alonso and Raikkonen having three wins apiece, and Hamilton and Massa getting two each.
Alonso is hoping to use today's race to overtake Hamilton for first place in the season standings.