In a nail-biting session, Bottas saw off the five-time world champion by just 0.023 seconds at the Shanghai International Circuit.
The form guide indicated that Ferrari might be the team to beat here, but after they were off the pace at the last round in Bahrain, Mercedes returned to their all-conquering best.
— Mercedes-AMG F1 (@MercedesAMGF1) April 13, 2019
Sebastian Vettel was a third of a second down on Bottas' Silver Arrows, with team-mate Charles Leclerc fourth. Red Bull's Max Verstappen finished fifth.
The Dutchman was furious after he failed to cross the line in time to post a final lap.
"It has been a good weekend so far," said Bottas, who leads Hamilton in the championship by just one point. "I struggled to get the perfect lap in, but it was good enough."
Hamilton, a five-time winner in China, said: "I didn't give up and kept pushing right to the end.
"Valtteri has been stellar all weekend. I have struggled. There is time left on the table, but I will try and get it back tomorrow."
Lando Norris fell at the second hurdle of qualifying for the first time in his short career.
The 19-year-old collected his inaugural points with a fine drive to sixth in Bahrain a fortnight ago, but faces a fight for another top-10 finish, finishing only 15th.
Norris was half-a-second slower than Carlos Sainz in the sister McLaren. The Spaniard will start just one spot higher than Norris on a disappointing afternoon for the British team.
George Russell described his lap as awful, but the English novice still managed to put his under-performing Williams ahead of his team-mate Robert Kubica on the grid.
Russell, who lines up in 17th, has now out-qualified the Pole, back in the sport eight years after his horror rally crash, at all three rounds.
The Williams cars will not be on the final row for tomorrow's race after London-born Alexander Albon and Alfa Romeo driver Antonio Giovinazzi played no part in qualifying.
Albon, who races under the Thai flag, wrote off his Toro Rosso following a 130mph shunt on the exit of the final corner in practice on Saturday morning.
Albon, 23, walked away unscathed and was given the all-clear by trackside medics, but his team were unable to get his car ready in time. Giovinazzi meanwhile was restricted to the garage with a mechanical issue.