Third seed Williams, 38, was sluggish in the opening set before raising her intensity to win 2-6 6-2 6-2 against 26th seed Stephens in New York.
"It was intense, we always have some incredible matches," she said.
Williams, aiming for a record-equalling 24th Grand Slam singles title, faces Greek 15th seedย Maria Sakkariย next.
Sakkari, 25,ย beat Williams in the three setsย at the Western and Southern Open last week.
Williams gave a damning self-assessment after losing to Sakkari, saying there were "really no excuses" after she let a set and a break lead slip in that match.
Now she has a chance to quickly avenge the loss after showing her fighting qualities against 2017 champion Stephens.
While Williams' game is still nowhere near the devastating levels that have won her 23 major titles in singles, the grit and determination showed in switching gears against Stephens will have sent a message to the rest of the field.
Whether that will be enough to win another Grand Slam, moving level with Australian Margaret Court's record and putting the demons of losing her past four major finals behind her, remains to be seen.
Against Stephens, it was a tale of contrasting opening sets. The younger American dominated the first with Williams lacking intensity, before the roles eventually reversed in the second.
Stephens tried to move 38-year-old Williams around the court in the opener and then picked her off with blistering winners.
"In that first set I don't think she made any errors, she was playing so clean," said Williams.
As you would expect from a former Grand Slam champion, Stephens has plenty of class to trouble the very best.
Yet, the 27-year-old has struggled for consistency in the past couple of seasons and went into the match against Williams having not beaten a top-10 player for almost two years.
That inconsistency showed as the match wore on.
Stephens was gifted an opportunity to break for a 3-2 lead in the second when Williams, who was breathing heavily between serves, produced a double fault.
However, Williams discovered her most potent weapon - her first serve - to hold and demoralise Stephens.
Her level dipped from that point as a rejuvenated Williams won 10 of the last 12 games to continue her record of reaching at least the fourth round in every US Open appearance since 1999.
"I just said I don't want to lose in straight sets, because she was playing good," said Williams, who last won the title at Flushing Meadows in 2014.
"I said, 'Serena, just get a game, get a game' and the next thing I knew I won the second set."
๐๐๐