"We know this track is one that suits us, so if we can extract every bit of that out of the auto we may have a shot at fighting for big points this weekend, so it has been a good day".
World championship leader Sebastian Vettel had a hard session, spinning off, complaining of oversteer and at one stage losing a part of his Ferrari vehicle after riding the kerbs.
Ricciardo has posted five podium finishes in 2017, including a win in Azerbaijan last month.
Vettel, the championship leader, leads Hamilton by one point after 10 races.
Ferrari's Kimi Raikkonen, second fastest in the morning, was fourth behind fellow-Finn Valtteri Bottas after lunch.Vettel had been more than a second slower than Ricciardo in sixth place on a warm but cloudy morning at the Hungaroring outside Budapest.
The session was twice stopped by red flags as a couple of drivers found themselves in hot water.
McCain says time for Republicans, Democrats to 'start fresh' on healthcare
John McCain , R-Ariz., arrives for a Senate Republican meeting on a health reform bill on Capitol Hill in Washington. Republicans have 52 seats in the Senate but Mr Trump has failed to coalesce his party around a healthcare strategy.
"Struggling a lot with oversteer and rear tyres didn't seem to be ready", the German said over the team radio.
The German clouted the barrier with the front-right and then ricocheted into an adjacent barrier, damaging the left-hand side of the auto.
Further down the field and it was a miserable day for Renault's Jolyon Palmer, who is yet to score a point this year and is under increased scrutiny ahead of Robert Kubica's comeback drive in next week's Budapest test.
Ricciardo was quickest in the first practice session and spent much of the second topping the timesheets.
Vettel had a patchy run in P1, losing control of the rear of his auto and spinning on Turn 9.
Earlier in the session, Romain Grosjean also ran of track, sliding gingerly into the tyre barrier and damaging the rear wing.
Both Haas drivers crashed at the fast Turn 11, Romain Grosjean incurring only light damage, but reserve driver Antonio Giovinazzi bringing out a red flag when he buried his vehicle in the wall, damaging the left-hand side.