Dani Pedrosa edged out fellow title contender Jorge Lorenzo by just 0.018 seconds in qualifying to take pole position for the San Marino Grand Prix.
Honda rider Pedrosa finished on one minute 33.857 seconds in the first sustained dry running of the weekend.
Championship leader Lorenzo looked to have taken pole in 1:33.875, but could not improve on his time at the death.
England's Cal Crutchlow took third and Northern Ireland's Jonathan Rea finished ninth on his MotoGP debut.
The narrow difference in time separating the two Spaniards in qualifying is reflected in the championship standings, with Lorenzo only 13 points ahead of his compatriot with only five races to go after Sunday's race.
"It was a really hard session, and at the beginning I tried to get the pace as we only had one hour with dry conditions beforehand," Lorenzo said.
"Finally, with so little I did not get the pole but we are very close, and everybody is waiting for a big battle tomorrow."
While Pedrosa ended the session with the fastest time, Tech 3 rider Crutchlow had looked poised to take his first ever MotoGP pole position before being usurped in the last few minutes.
He said: "I am feeling really confident after scoring my first podium in Brno and the good thing is we have carried that momentum to here.
"Hopefully we can put on a good show for all the fans that turned up yesterday and this morning when not a lot was happening on track."
The session was also a positive one for debutant Rea, who is standing in for Casey Stoner at Honda as the Australian recovers from ankle surgery.
"I am just learning with every single run and you cannot give anything away to these guys," the 25-year-old said. "I am really enjoying this experience and do not want it to end.
"It was all or nothing, and I have to be happy with a third row start. The limit is still quite far away and I do not want to reach it yet."
Qualifying times for San Marino MotoGP:
1. Dani Pedrosa (Spain) Honda 1:33.857
2. Jorge Lorenzo (Spain) Yamaha 1:33.875
3. Cal Crutchlow (Britain) Yamaha 1:34.001
4. Stefan Bradl (Germany) Honda 1:34.221
5. Alvaro Bautista (Spain) Honda 1:34.299
6. Valentino Rossi (Italy) Ducati 1:34.619
7. Andrea Dovizioso (Italy) Yamaha 1:34.916
8. Ben Spies (U.S.) Yamaha 1:34.988
9. Jonathan Rea (Britain) Honda 1:35.358
10. Nicky Hayden (U.S.) Ducati 1:35.401