Lewis Hamilton on Malaysian GP pole after torrential rain
Hamilton held on with a time set on his first flying lap despite not improving on his final run as Vettel got to within just 0.074 seconds of him.
The Briton's team-mate Nico Rosberg took third after appearing to delay the world champion on his penultimate lap.
Toro Rosso's Max Verstappen, 17, was a stunning sixth in only his second race.
The Dutchman was just behind the two Red Bulls of Daniel Ricciardo and Daniil Kvyat.
Vettel's team-mate Kimi Raikkonen hit traffic on the only lap before a tropical downpour hit in second qualifying and will start 11th in the race which starts at 08:00 BST on Sunday.
The Finn, who had been neck-and-neck with Vettel all weekend until that point, said: "We got it wrong. We should have been out earlier but that's how it is."
Hamilton was right behind Raikkonen on the track after a delay exiting his garage, but managed to sneak through into the top 10 shoot-out in eighth place.
After a half-hour wait for the spectacular thunderstorm and torrential rain to abate, Hamilton set a blistering pace on his first lap, more than a second clear of Rosberg.
The two Mercedes came in for a fresh set of intermediate tyres and Rosberg returned to the track ahead.
After being delayed behind Williams's Valtteri Bottas at the first corner of what would have been his first flying lap, Rosberg backed off and in doing so it appeared as if he might have delayed Hamilton after the Englishman had just set what was his fastest first sector time to that point.
Hamilton backed off and then failed to improve on his final lap. Rosberg did, ending up 0.465secs off his team-mate but unable to beat Vettel.
"The first lap was quite good," he said. "It's always difficult because none of us had driven this weekend in the wet and the first lap is an unknown. You don't want to take too many risks but you need a banker."
Hamilton set his fastest first sector time on his final lap but said that he "lost time" on the rest of the lap.
Ricciardo was more than a second back in fourth place but 0.4secs quicker than team-mate Kvyat, who snuck ahead of the impressive Verstappen by just 0.03secs.
The top 10 was completed by Williams duo Felipe Massa and Bottas, Sauber's Marcus Ericsson and Lotus's Romain Grosjean, who had qualified eighth but dropped two places after being punished for a pit lane infringement in Q2.
Jenson Button beat team-mate Fernando Alonso on the Spaniard's first race of the season but the McLarens could manage only 17th and 18th.
Alonso had been ahead on their first runs, as he had been all weekend on one-lap pace, but made a mistake on his final lap and Button edged him by 0.11secs.
The Spaniard said he "lost the car in Turn Six" and lost several tenths of a second, but did not feel that was enough to prevent him progressing into the second part of qualifying.
Nevertheless, McLaren's performance was an improvement on the first race of the season. The team were 0.6secs away from making it through into second qualifying - a step forward of about a second a lap compared to Melbourne two weeks ago.
Manor Marussia, who failed to participate at the Australian GP, were given a reprieve by stewards and will start Sunday's race despite failing to set a qualifying time within the required 107% of the fastest time in Q1.
Roberto Merhi's best time fell short, while Will Stevens failed to get out in qualifying because of a fuel system issue.