Shelton had flummoxed opponents in New York with his big serve but the 36-year-old second seed Djokovic was able to harness his experience to neutralise a third-set surge from the young American.
He next faces the winner of a match between top seed and defending champion Carlos Alcaraz and third seed Daniil Medvedev.
"These are the kind of matches and occasions that I still thrive on, that still get me going," Djokovic said on court.
Shelton handed Djokovic a break in the sixth game of the first set with a series of unforced errors, and the unseeded American was unable to convert his own break point chance in the ninth.
Playing in only his seventh U.S. Open singles match, Shelton triumphed in a 30-shot rally before converting a break point in the eighth game, humbling Djokovic, who was appearing in his 100th singles match at the hardcourt major.
Persons:
Serbia's Novak Djokovic, Ben Shelton, Mike Segar, Novak Djokovic, Arthur Ashe, Shelton, Djokovic, neutralise, Carlos Alcaraz, Daniil Medvedev, Margaret Court's, humbling Djokovic, Amy Tennery, Toby Davis
Organizations:
Tennis, U.S, REUTERS, Thomson
Locations:
Flushing Meadows , New York, United States, Serbian, U.S, New York, American