The Briton was just 0.055 seconds quicker than the defending world champion, as Nico Rosberg narrowly beat Ferrari’s Fernando Alonso to third.
Red Bull’s Daniel Ricciardo was fifth ahead of Ferrari’s Kimi Raikkonen.
I had to bail out of my final fast lap, so it was very close
Hamilton, whose pole position was the 33rd of his career, was delighted to clinch first place in such testing conditions.
“I’m all over the place at the moment,” said Hamilton. “I’m really happy with how well we’ve done over the weekend, but today was incredible – how heavy was the rain?
“It was tricky out there for everyone because at the end it was almost impossible to see.
“I couldn’t see where the track went, where the corners were, where to brake. I had to bail out of my final fast lap, so it was very close.”
Hamilton, who was forced to retire from the season-opening Australian Grand Prix earlier in the month, is determined to make amends at Sepang.
“For myself and for the team, the priority is to bag as many points as possible,” he continued.
“We’ve got great a great opportunity, a great car and a team that is performing fantastically right now. Fingers crossed we can see ourselves through to the finish line.”
Meanwhile, Red Bull’s Vettel insisted that he was pleased with his performance.
“It was very close, too close,” said Vettel. “I should be on the good side for tomorrow but it depends on how good the start is. I’m happy with the result.”
1. Lewis Hamilton Britain Mercedes-Mercedes 1m 59.431s
2. Sebastian Vettel Germany Red Bull-Renault 1m 59.486s
3. Nico Rosberg Germany Mercedes-Mercedes 2m 00.050s
4. Fernando Alonso Spain Ferrari-Ferrari 2m 00.175s
5. Daniel Ricciardo Australia Red Bull-Renault 2m 00.541s
6. Kimi Raikkonen Finland Ferrari-Ferrari 2m 01.218s
7. Nico Hulkenberg Germany Force India-Mercedes 2m 01.712s
8. Kevin Magnussen Denmark McLaren-Mercedes 2m 02.213s
9. Jean-Eric Vergne France Toro Rosso-Renault 2m 03.078s
10. Jenson Button Britain McLaren-Mercedes 2m 04.053s
11. Daniil Kvyat Russia Toro Rosso-Renault 2m 02.351s
12. Esteban Gutierrez Mexico Sauber-Ferrari 1m 02.369s
13. Felipe Massa Brazil Williams-Mercedes 1m 02.460s
14. Sergio Perez Mexico Force India-Mercedes 1m 02.511s
15. Valtteri Bottas Finland Williams-Mercedes 1m 02.756s
16. Romain Grosjean France Lotus-Renault 1m 02.885s
17. Pastor Maldonado Venezuela Lotus-Renault 2m 02.074s
18. Adrian Sutil Germany Sauber-Ferrari 2m 02.131s
19. Jules Bianchi France Marussia-Ferrari 2m 02.702s
20. Kamui Kobayashi Japan Caterham-Renault 2m 03.595s
21. Max Chilton Briton Marussia-Ferrari 2m 04.388s
22. Marcus Ericsson Sweden Caterham-Renault 2m 04.407s
MORE: The latest football news
MORE: The latest tennis news
BIOGRAPHY: Daniel Sturridge
BIOGRAPHY: Kepa Arrizabalaga