Hamilton appeared unstoppable in practice, comfortably leading the way, and seemed so again after the first two qualifying periods at the Circuit Gilles Villeneuve.
But the Briton was denied a fourth pole in eight attempts at Montreal as championship rival Rosberg pulled a rabbit out of the hat in the top-10 shoot-out to edge Hamilton by 0.079secs.
Hamilton's first flying lap in Q1 saw him make a mistake into turn one, but he soon made amends to finish the session three-quarters of a second quicker than Rosberg.
By the end of Q2 the deficit between the duo had been cut to four-tenths of a second, and come the final blast Rosberg countered to lead the way by just 0.068secs after the first run.
On the second and final hot lap Hamilton had the edge after the first sector, but a lock-up into turn eight in the second sector cost him dear to leave Rosberg leading away the field for the second successive race.
Reigning four-times champion Sebastian Vettel was the best of the rest, albeit seven-tenths of a second adrift of Rosberg, such is the gap betweenNico Mercedes and Red Bull.
Williams pair Valtteri Bottas and Felipe Massa, who have looked strong this weekend, will start fourth and fifth ahead of Daniel Ricciardo in his Red Bull.
Ferrari pair Fernando Alonso and Kimi Raikkonen, who had seemed set to challenge here, could only manage seventh and 10th places.
Sandwiched in between the pair will be Toro Rosso's Jean-Eric Vergne and Jenson Button in his McLaren.
The Force India duo of Nico Hulkenberg and Sergio Perez start 11th and 13th, either side of Kevin Magnussen in his McLaren.
Magnussen finished less than a tenth of a second slower than team-mate Button, yet finished four places behind him as the 34-year-old was eighth quickest in Q2.
Lotus' Romain Grosjean lines up 14th ahead of Daniil Kvyat in his Toro Rosso and Sauber's Adrian Sutil.
Pastor Maldonado's run of rotten luck shows no sign of ending as the Venezuelan pulled his Lotus off track towards the end of Q1.He will start 17th.
Max Chilton missed out on a place in Q2 by just over a tenth of a second to underline Marussia's recent improvement, with the Briton to line up 18th ahead of team-mate Jules Bianchi.
Caterham, now almost a second off the pace of Marussia, have Kamui Kobayashi and Marcus Ericcson in 20th and 21st respectively.
Ericsson brought a premature end to Q1, albeit only by 16 seconds. He lost control of his car at the turn eight/nine chicane, where he smashed into a wall, breaking off the rear left wheel.
Esteban Gutierrez will start at the back of the grid after failing to take part in qualifying following an earlier crash in final practice in his Sauber.
The Mexican spun 180 degrees through the turn three/four chicane before slamming sideways into a barrier, sustaining chassis damage that could not be repaired in time by his team.
Rosberg, who has never started higher than fourth in previous years, knows he has struck a psychological blow over Hamilton.
"I know it's a track where Lewis is really strong, so I'm very happy it has worked out," said Rosberg.
"It has been a fantastic day, and through the weekend we have been progressing all the time and I'm in the best position for tomorrow."
Hamilton, meanwhile, knew he had been beaten fair and square on this occasion. He said: "Nico did a fantastic job, so congratulations to him.
"My final lap was not particularly bad, it just wasn't the greatest qualifying.
"Sometimes you have a good qualifying, sometimes you have bad qualifying.
"It's a great to get a one-two for the team, a fantastic performance. Let's hope we can make history tomorrow."
That was with reference to the fact that a one-two in the race will set a new F1 record of six in a row.