The German, who out-qualified team-mate Mark Webber for the first time this year, was 0.098 seconds quicker than Hamilton, with Webber third.
McLaren's Jenson Button was fourth, ahead of Mercedes' Nico Rosberg.
Ferrari's Fernando Alonso and Force India's Paul di Resta did not set a time and are ninth and 10th.
Both men preferred to save a set of tyres for the race because tyre life is expected to be a critical factor.
The same reason lies behind Lotus driver Kimi Raikkonen, whose team-mate Romain Grosjean is seventh, failing to make it into the top 10.Raikkonen said he "could easily" have got into final qualifying but preferred to save a set of tires for the race.
The chief beneficiary of all this strategic play was Toro Rosso's Daniel Ricciardo, who qualified a stunning sixth, ahead of Grosjean and Sauber's Sergio Perez.
Rosberg's team-mate Michael Schumacher will start 17th after failing to get out of the first qualifying session.
Vettel has had a difficult start to the season, uncomfortable in Red Bull's new car, and before Bahrain his highest qualifying position was fifth.
But Red Bull's race pace has been strong and Vettel said he was optimistic of a good result in the grand prix.
"We should be better off in the race," he said. "Our race pace has proven to be consistent in the last couple of races.
"I'm happier with the way the car feels. We should be able to get the same kind of feeling and result on Sunday.
"I'm looking forward to the start and then I think it will be very tight. I think Nico [Rosberg] has been very strong all weekend and the Lotus guys can surprise.
"In terms of race pace, I think everyone will be much closer together."
Vettel said his pole owed much to intense work by the team to understand better the car.
"We have been busy working on the car," he said, "trying to find the perfect solution and the right way to go forward. I don't think the boys had much sleep the last four races.
More of this report at BBC Formula 1 Sport
Tweet