The Formula One championship leader struggled during Friday practice as his Mercedes was nowhere near the pace of his main title rival Sebastian Vettel.
Unfortunately for Ferrari’s Vettel, who is 28 points adrift of Hamilton in the drivers’ standings, he suffered engine trouble and was unable to set a qualifying lap so will start from the back of the grid.
Hamilton, meanwhile, hooked up a superb lap to claim his fifth pole in Malaysia for what is likely to be the last grand prix at Sepang.
“We had such a difficult day (on Friday) and it was difficult to know where we stood. I didn’t sleep well last night because we just didn’t know if we would fix the issue,” he said.
“Today we arrived and the car was much better, it still looked like the Ferraris were a bit ahead so we had some big calls to make.
“The first Q3 lap was very well put together, a very nice lap and I don’t know where it came from to be honest, so I surprised myself.
“It is always a special thing when you are able to extract a little more out of the car than it is willing to do.”
Hamilton was pushed all the way by the second Ferrari of Kimi Raikkonen, who starts second, with the Briton offering condolences to Vettel after his engine woes.
“I don’t really know what happened to Sebastian but he would have been up here with us. He had been driving well all weekend and it is very unfortunate for him,” he said.
“We have to maximise every opportunity we can get, we have put ourselves in the best position possible but we will keep our heads down and behind me it will just unfold the way it is going to unfold.”
Vettel had surprisingly held the upper hand over Hamilton throughout practice but suffered an issue in the final session and required a new engine.
Although his mechanics completed the work in time for qualifying, Vettel complained of a lack of turbo during his first timed run and ultimately sat the session out in the garage to leave him at the back of the grid today. “It’s part of motor racing,” the German said.
“It’s not ideal, not what you want when you think you’ve got it in you. We’ve saved some tyres so that’s a positive but it’s a very bad day.
“We need to see now what the problem was. The guys worked a miracle today and did the change successfully in time. They fixed it quickly and it’s a shame I couldn’t get out – but we go tomorrow.”
Max Verstappen will start third after a strong showing on his 20th birthday with his Red Bull team-mate Daniel Ricciardo in fourth.
The second Mercedes of Valtteri Bottas was fifth fastest and will start ahead of Esteban Ocon’s Force India while Stoffel Vandoorne was seventh for McLaren.
Renault’s Nico Hulkenberg will start eighth with Segio Perez ninth for Force India and Fernando Alonso rounds off the top 10 in his McLaren.