The Finn picked up his first top spot in qualifying to beat his British team-mate and Ferrari's Sebastian Vettel, who have one win apiece in this year's championship, into second and third place on the grid respectively.
Hamilton finished just 0.023 slower than Bottas's lap of one minute 28.769 seconds, to secure the first front row lockout of the season for the reigning champions.
Red Bull's Australian Daniel Ricciardo will start alongside Vettel in fourth.
Mercedes, who won the race last year with now-retired champion Nico Rosberg, have taken five successive poles at the desert Sakhir circuit.
1. Valtteri Bottas (Finland) Mercedes
2. Lewis Hamilton (Britain) Mercedes
3. Sebastian Vettel (Germany) Ferrari
4. Daniel Ricciardo (Australia) Red Bull - TAG Heuer
5. Kimi Raikkonen (Finland) Ferrari
6. Max Verstappen (Netherlands) Red Bull - TAG Heuer
7. Nico Huelkenberg (Germany) Renault
Read the full article on eurosport.co.uk: Bottas stuns Hamilton and Vettel to take pole in Bahrain