He improved his time by a second to go top by half-a-second from Hamilton shortly after the half-hour mark, with Ferrari driver Kimi Raikkonen also completing a relatively early lap on mediums to go third.
But both Mercedes drivers were soon out on the medium Pirellis, with Rosberg momentarily taking top spot with 51 minutes to go before Hamilton set a time 0.449s faster.
Ricciardo's lap was good enough to hold third, with home hero Fernando Alonso jumping ahead of Raikkonen.
Pastor Maldonado, the first driver to set a time on the mediums which briefly elevated him to fourth fastest, was shuffled down to ninth by the end of the session ahead of Toro Rosso's Daniil Kvyat.
Lotus team-mate Romain Grosjean was only 17th after a troubled session, initially complaining of a lack of rear-end downforce before being called in with a braking problem that potentially made the car unsafe.
Force India had a quiet session, with Nico Hulkenberg the faster of its drivers in 11th place ahead of Jean-Eric Vergne, whose session came to an end with five minutes to go after his right-rear wheel flew off after he had stopped to change tyres.
Behind them was Adrian Sutil in the improved, lightweight Sauber-Ferrari C33, a car he hopes will allow him to fight for a points finish for the first time in 2014 this weekend.
Sebastian Vettel sat out the session after completing only four laps in the morning thanks to an electrical problem.
His Red Bull squad discovered that the wiring loom had been damaged, meaning there was not enough time to get the car fixed and back out on track.
Marussia driver Max Chilton also hit trouble, suffering an engine problem that restricted him to only in-and-out laps early in the session before completing some meaningful running later on.
He ended the session in the gravel at Turn 4 after what appeared to be a driver error.
He also caused a yellow flag at the entry to the final corner when his Marussia shed a piece of bodywork that had to be recovered by a marshal.
Track conditions were good throughout the session, with the ambient temperature around the 23-24C mark and track temperatures in the mid-40s.
- Motor Racing
- Sports & Recreation
- Daniel Ricciardo
- Kimi Raikkonen