Keys upsets Pegula in all-American clash to reach lsat eight
Keys crashed out of the first round at Cincinnati last month but appeared right at home on the New York hard courts, where she was runner-up in 2017, as she overwhelmed her opponent with 21 winners.
Pegula beat the 17th seed Keys in their only previous meeting last year and was considered as one of the US' brightest hopes after winning the Montreal title last month.
However, on Monday she lacked her usual firepower and finesse.
"I've had so many amazing moments in New York," said Keys, who is playing in her 12th US Open main draw.
"Being able to at any moment come back from any difficult positions I've been in matches has been amazing."
Vondrousova victorious
She next plays Wimbledon champion Marketa Vondrousova (24), who overcame a rocky start to beat American Peyton Stearns (21) 6-7, 6-3, 6-2.
Keys broke her opponent's serve with a backhand winner in the second game of the first set and broke Pegula again on the fourth try in game six.
Pegula was clearly off her game and threw her racquet down in frustration as she helped Keys to the break with a double fault and a backhand error in the fifth game of the second set.
Pegula broke back immediately in the sixth game but Keys kept her cool, retaking the lead as she broke her opponent's serve in the seventh game.
Keys, who counts Pegula as a close friend, pumped her fist in a subdued celebration as the top-ranked American dropped her serve again when she sent a forehand shot into the net on match point.
"It's always tough having to play a friend... when we get on the court it's all business," she said in courtside interview.