The Russian lost 4-6 6-3 6-1 and in doing so, Novak Djokovic will return to the top of the world rankings as of Monday.
Medvedev - who lost to Rafael Nadal in the 2022 Australian Open final - has not had the best run since overtaking Djokovic as the men's best player.
He once again fell short to Nadal at the Mexican Open semi-finals and has now been eliminated early from Indian Wells.
His reign as world number one saw him with just one win against Tomas Machac in the previous round of the tournament.
For Monfils, he earned his first win over a world number one in 13 years and has now set up a meeting with Spanish teenager Carlos Alcaraz - who beat fellow native Roberto Bautista Agut 6-2 6-0 in his most recent match - in the fourth round.
"I'm quite happy right now - I'm in my zone," Monfils said. "I moved quite good and then I changed the speed quite a lot.
"I knew I was in great shape and tough to beat," he added. "It's always special to beat a world No 1.
Nadal continues sensational start
Meanwhile, Nadal continued his unbeaten start to the season, defeating Dan Evans to earn his 400th win at the Masters 1000 level.
The 21-time Grand Slam champion furthered his lead over his rivals, with Roger Federer winning 371 and Djokovic 374.
Recovering from an early break, Nadal went on to defeat Evans 7-5, 6-3, and now has a record of 17-0 for the year.
In his post-match interview, Nadal said: "I started playing better and better and think I finished the match well, so that's important for the confidence and playing a tough opponent like Dan.
"It's a good victory for me, so I'm very happy to beat Dan in the third round and happy to be here.
"The match in the beginning was difficult. He put me under some pressure combining his great slice backhand and the bounce has been quite low.
"It was not easy in the windy conditions here to put him in a tough position, but I hit a couple of passing shots in some important moments."