The British driver, who clocked the fastest lap of one hour and 17.281 seconds, was was just 0.013 seconds ahead of Bottas, the Formula1.com reported.
Hamilton, whose Barcelona pole time is three seconds faster than last year's on a resurfaced track, expressed frustration that the 2019 rules will result in cars that are 1.5 seconds slower and "pull us back".
He won at this track in 2017, though, and with Mercedes locking out on the front row, Hamilton can hope for some assistance in keeping Vettel at bay.
Hamilton is now standing at the top spot in the drivers' championship, maintaining a lead of just four points over Vettel.
This was Hamilton's second pole of the season, having taken the top spot at the season-opener in Australia in March.
"I had a mistake on the first run in Q3, which meant I only had one proper shot at it - that was a good run and, of course, if you do the laps again then you can always find something more".
"I think overall the tyres this weekend are different".More news: Madrid Open: Thiem stuns Nadal in quarter-finals
More news: Lomachenko's Stunning KO Of Linares As Mick Conlan Coasts To Another Victory
More news: Boston Dynamics' Atlas humanoid jog like humans
"Since getting pole in Australia for the first race, we've not had another good qualifying until today", said...
Lewis Hamilton may be leading the 2018 Drivers table, but he's not managed a pole position since the opening race of the 2018 F1 season. "Ferrari looked to be sandbagging because they could". We can be better.
When it mattered in Q3, he set a blistering lap on his first run and with the pressure on, the 33-year-old promptly improved it, taking pole with a time of 1min 16.173sec. Lewis had a very good qualifying and, for us, as Lewis said, it's a ideal result for us and hopefully we can continue like this tomorrow.
"It wasn't bad but we needed more laps".
"Everything we put on the vehicle seems to work and that's important", Vettel said.
Raikkonen conceded the supersoft tyres, which have given teams a headache this weekend, continued to pose a challenge for Ferrari, and he highlighted the thinner tread being used this weekend as a possible factor.
"So, it was definitely important, and I am happy too especially because I had such a busy week coming into this weekend". "If there is time and anyone wants to approach me or any of the drivers, I am sure we can give some good insight".
"Not to say that we know everything, we don't anything about engineering the vehicle, but we know how the cars feel, how to drive the cars, and their limitations to overtake".