The South Africa, Anderson, who made the French Open fourth round in 2013 and 2014, twice recovered from a set down to advance 6-7 (6/8), 7-6 (7/4), 5-7, 6-1, 6-4 in just under four hours.
A former top 10 player, the world number 56 will meet Croatian seventh seed Marin Cilic for a spot in the quarter-finals.
Defeat for Edmund, born in Johannesburg like Anderson, means Britain have still never had more than one man in the last 16 at Roland Garros in the Open era.
Anderson missed this year’s Australian Open with a hip injury. His best Grand Slam performance was his run to the 2015 US Open quarter-finals.