Vettel finished just 0.041 seconds clear of Valtteri Bottas under the lights of the Sakhir Circuit, with Red Bull's Daniel Ricciardo in third and Hamilton, a winner last time out in China, only fifth.
Hamilton, who is level on points with Vettel at the summit of the championship heading into Sunday's third round, was a quarter-of-a-second off Vettel's best time.
But the Briton saw a number of his best laps scuppered by heavy traffic and is unlikely to be alarmed by his position down the order.
Nevertheless, Vettel and his Ferrari team will be buoyed by their form as their fight with Hamilton shows little sign of relenting.
"It was incredibly hot early on, with some of the very toughest conditions, both physically, and in terms of working with the tyres," Hamilton said afterwards.
"It was very close, with Ferrari fastest.
"In race trim they seem a couple of tenths quicker, so I'm expecting a great battle tomorrow and then again on Sunday. We'll work as hard as we can to try to close that gap."
It could have been much worse for Vettel, who appeared in significant trouble midway through the second session after reporting a problem with his Ferrari.
But the four-time champion managed to recover, albeit slowly, back to the pit lane before being pushed the final 100 metres by his mechanics back to the garage.
He was back on track only minutes later and the issue, yet to be diagnosed by Ferrari, did not rear its head again.
There were problems in the sister Ferrari, too as Vettel's team-mate Kimi Raikkonen's opening session came to a sudden halt with smoke billowing out of his engine.
The Finn, under pressure here after two underwhelming performances, was forced to pull over before he trudged back to the Ferrari garage without making any attempt to remove his crash helmet or lower his overalls despite the sweltering 40 degree heat.
He was back for the second session, however, and posted the fourth best time, 0.168secs slower than Vettel.
Fernando Alonso misses next month's Monaco Grand Prix as he heads to the United States to take on the Indianapolis 500, and the Spaniard, who will be replaced by Jenson Button, will be looking forward to the change of scenery.
He was 14th of the 20 runners in the second session, while there were further troubles for his McLaren team-mate Stoffel Vandoorne.
The Belgian rookie stopped at turn 10 in the opening practice session following another Honda engine problem which resulted in a delay to the start of his running later in the day. Further reliability woes contributed to him completing only eight laps and propping up the order.
Bernie Ecclestone, the sport's one-time long-serving ruler, is back for the first time this weekend after being ousted by new owners Liberty Media.
And the 86-year-old watched on from the confines of the Red Bull motorhome - first with team principal Christian Horner and then Niki Lauda, Mercedes' non-executive chairman - before being swept out of the paddock on the back of a golf buggy.
Elsewhere, Nico Hulkenberg was an impressive sixth for Renault, while his British team-mate Jolyon Palmer was 13th in the order.