French world number 28 Monfils produced a vintage performance to down Medvedev 4-6, 6-3, 6-1 in just over two hours to advance to the fourth round.
It was the first time the 35-year-old Monfils has beaten a player ranked world number one since 2009.
The defeat means Novak Djokovic will return to the top of the world rankings, three weeks after Medvedev took top spot on February 28.
Monfils sealed victory in 2hr 6min after converting his sixth match point in brilliant sunshine at the Indian Wells Tennis Garden in the California desert.
The veteran Frenchman thumped his chest and pointed at his Ukrainian wife Elina Svitolina in the stands following a superb performance.
"I've had a strong start to the year, felt strong, moving good," Monfils said.
"I'm in my zone and I'm a tough opponent for anyone. It's been a long time since I've beaten a world number one, so I'm pretty happy."
Reigning US Open champion Medvedev had looked to be in control after clinically taking the first set immediately after breaking Monfils for a 5-4 lead.
Monfils broke early for a 3-1 lead in the second set, but Medvedev broke back to level at 3-3.
Monfils earned set point in the eighth game with a brilliant backhand up the line before clinching the second set with a cheeky underarm serve.
Medvedev's composure evaporated in the deciding set, with the Russian earning a code violation for smashing his racket in frustration after being broken in the first game.
Monfils held and then went a double break up before holding again for a 4-0 lead.
With the next two games going on serve, Medvedev was soon in trouble in the seventh game, going 0-40 and three match-points down after blasting an overhead smash long.
The Russian did well to claw back those three match points, and saved two more before Monfils finally converted his sixth.
Monfils, the 26th seed, will face rising Spanish star Carlos Alcaraz in the fourth round.
Alcaraz, seeded 19, advanced to the last 16 with a confident 6-2, 6-0 demolition of compatriot Roberto Bautista Agut, the 15th seed.
In the women's singles on Monday, Russia's Veronika Kudermetova advanced with to the last 16 after Czech opponent retired in the second set. Kudermetova was 6-4, 0-2 ahead when her opponent conceded defeat.
Greece's Maria Sakkari, looking to build on a breakout 2021 which included two Grand Slam semi-finals appearances, overwhelmed the Czech Republic's Petra Kvitova in straight sets.
Sakkari booked her place in the fourth round with a 6-3, 6-0 win over the two-time Wimbledon champion.