Monfils completed the upset on the sixth match point in front of a vocal California crowd with a backhand winner to set up a meeting with Spanish teenager Carlos Alcaraz in the next round
Daniil Medvedev broke the Frenchman in the ninth game of the first set after a pair of double faults and two forehand errors. The reigning U.S. Open champion looked to be in complete control and dropped just four points on his serve in the opening set.
Fortunes soon turned for Medvedev as the Russian lost the momentum in the second set, unable to make the most of his opportunities by failing to convert five of the six break-point on offer.
Monfils broke Medvedev in the fourth game with a backhand winner and again in the eighth with a fiery forehand to take the second set 6-3. The deciding set was not even close as Monfils won the first four games before going on to win the set 6-1.
It was the first time in 13 years that the 35-year-old Monfils has beaten a number-one ranked player in the world.
Twenty-times Grand Slam winner Novak Djokovic will return to the top of the world when rankings when are updated next Monday.