Grosjean'splacing is comfortably the team's best qualifying performance of the year after a difficult start to the season.

The team have been battling reliability problems after a late start to pre-season testing but after making progress in the first four races are finally in a position to exploit the car's potential.

McLaren's Jenson Button was eighth ahead of the Williams of Felipe Massa. Red Bull's Sebastian Vettel was 10th, failing to set a time in the top 10 shoot-out after his car lost drive coming out of the pits at the start of the session.

"It's been a tough day," Hamilton said. "Nico has been driving really well so I didn't know whether I'd be able to get it. But right at the end I managed to get absolutely everything out of the car."

Hamilton, celebrating his fourth pole of the season and 35th of his career with a time 0.168 seconds quicker than the German, will take the overall lead in the standings if he wins at the Circuit de Catalunya.