Sebastian Vettel ended in second place, just 0.093s behind his rival, but faces the possibility of a grid penalty after being called before the stewards.
"I think some of it is still a mystery but I think there are a lot of areas that we have understood", Hamilton said.
It wasn't all plain sailing for Hamilton, however, with the British driver twice encountering issues with traffic, once with Ferrari's Kimi Raikkonen, while in a frightening second incident, Hamilton desperately tried to get out of the path of the hard-charging Williams of Sergey Sirotkin, the pair narrowly avoiding a nasty coming-together.
The German was handed a €25,000 fine and a reprimand, but stays on the front row alongside Hamilton.
"I think we have a good auto and in qualifying to be half a second off pole around here, where from memory we haven't been that close in the past, is positive", Ricciardo told redbullracing.redbull.com.
Hamilton's Mercedes team-mate Valtteri Bottas, who was the previous record holder with his lap for pole position past year, was third-quickest ahead of Sauber-bound fellow-Finn Kimi Raikkonen in the second Ferrari. I think collectively, as a team, we did a really good job to get the auto to a comfortable balance. "We all know to keep a gap".
The odd weather created a drama-inducing amount of caution from all the teams as they panicked about tyres and strategy.
"I am not going to be here if it gets to 25 races, that's for sure".
"That was some qualifying session", Hamilton said.
"It's not something I've asked Valtteri if he wants but I don't think he's going to want that".
"I'm hoping this weekend we can get the vehicle into the right place and fight the guys, and the Red Bulls and Ferraris who have seemed to come back more into shooting range. I'd be proud if it was what you think it is, but it's not".
Behind the big three, Swede Marcus Ericsson took a career-best seventh place - which will become sixth on the grid with Ricciardo's penalty for using too many engine parts - two races before what is likely the end of his F1 career.
"That was a tough session", he said.
"We have a battle on our hands for the constructors' title and we have lost ground to Ferrari in each of the past race weekends".
"So I don't think I'll be doing him any favours in the sense of giving him a win, I don't think he needs that".