The setback for the 26-year-old Medvedev will see him hand the top spot on the ATP back to Serbia's Novak Djokovic when the latest rankings are released next Monday.
The 35-year-old Monfils' 4-6, 6-3, 6-1 victory has now pitted the Frenchman against Carlos Alcaraz of Spain in the pre-quarterfinals.
"I played great tennis. I knew I was in great shape and tough to beat. It's always special to beat a world No. 1," said Monfils to atptour.com.
"I moved great. I was striking the ball very good and I'm full of confidence, so I'll try to keep the flow," added Monfils.
It's a second career victory over a current world No. 1 for Monfils, his first coming against Rafael Nadal in 2009 in Doha. He'll now turn his attention to 19th seed Alcaraz who thrashed compatriot Roberto Bautista Agut, 6-2, 6-0.
With Medvedev falling to Monfils and Germany's Alexander Zverev being upset by Tommy Paul, the fourth-seeded Nadal is the highest-ranked player remaining in the draw. The three-time Indian Wells champion will next face 17th seed Reilly Opelka of the US, who battled past Denis Shapovalov of Canada, 6-7(4), 6-4, 6-4.