Team mate Nico Rosberg, who is four points clear of Hamilton but has finished runner-up in the last three races, qualified second with Australian Daniel Ricciardo starting third for champions Red Bull.
Hamilton, celebrating his fourth pole of the season and 35th of his career with a time 0.168 seconds quicker than the German, will wrest the overall lead from Rosberg if he wins for the first time at the Circuit de Catalunya.
"I didn't know whether I'd be able to get it but right at the end I just had to eke out absolutely everything and more from the car," said Hamilton, who had been slower than Rosberg in final practice.
"To have the kind of performance we have, I have never really known that before. I'm overwhelmed, I'm so happy," added the 2008 champion, whose dominant team have taken every pole and won all four races so far this year.
Ferrari's Fernando Alonso, winner in front of his home fans last year, qualified seventh and behind team mate Kimi Raikkonen in sixth.
Finland's Valtteri Bottas starts fourth for Williams, with Frenchman Romain Grosjean fifth for Lotus.
Red Bull's quadruple world champion Sebastian Vettel will line up in 10th place on the grid after stopping on track in the final phase of the session.
Vettel has switched to a different chassis for the start of the European season after a difficult opening four races in Asia and the Middle East but his luck has, if anything, taken a turn for the worse.
He managed only four laps in Friday practice before being sidelined by an electrical problem and on Saturday the gremlins returned at the crucial point.
"I left the garage and lost second gear," said the 26-year-old, who has been overshadowed by new team mate Ricciardo.
"It was clear there was a problem but I still had third gear and above so I thought I'd try without second gear. But by Turn One, I'd lost all the other gears."
McLaren, without a point from the last two races, also had problems with Danish rookie Kevin Magnussen unable to set a lap time in the second phase due to a power unit problem and qualifying 15th.
Team mate Jenson Button will start eighth.
Qualifying was twice red flagged, the second stoppage triggered by Vettel's failure and the first coming right at the start when Venezuelan Pastor Maldonado speared his Lotus into the wall.
Maldonado will be at the back of the grid, along with Toro Rosso's Jean-Eric Vergne who has a 10 place penalty after an unsafe release from the pits on Friday.