Vettel claimed his first pole of the Formula One season with a lap of 1 minute, 32.520 seconds, which was 0.98 seconds faster than Hamilton, who is driving for McLaren.
The win was a breakthrough of sorts for Vettel, who claimed a record 15 poles last season but had yet to make the front row this year. "It hasn't been the best start to the season for us," Vettel said. "We've been extremely busy working on the car, trimming here and there and finding the perfect solution."
There was more good news for Red Bull when Vettel's teammate Mark Webber qualified for a season-best third position.
The 57-lap Bahrain Grand Prix takes place Sunday despite continuing civil unrest in the streets. Anti-government demonstrations last year forced cancellation of the race.