World number 14 Berrettini came through 6-4, 6-4, 6-7 (1/7), 6-3, crunching 18 aces and 55 winners in total on Arthur Ashe Court.
A semi-finalist in 2019 and quarter-finalist last year, the 26-year-old will face Spain’s Alejandro Davidovich Fokina for a last-eight spot.
“I wasn’t aggressive enough in the third set but I was feeling better in the fourth. I had my chances and took them, finally,” said the Italian.
Berrettini had defeated Murray in the Stuttgart final in June and was in control from the start on Friday.
Murray double-faulted to hand the Italian the only break of the opening set in the seventh game and was a break to the good in the first game of the second set.
Murray hit back immediately but Berrettini’s powerful hitting kept the Briton on the back foot as he sealed a two-set lead courtesy of another break in the ninth game.
The British star roared back in the third set with a dominant tiebreak and was even a break up in the fourth before the 26-year-old Italian steaded himself to race to victory after three hours and 47 minutes.
The defeat leaves Murray without a fourth round spot at the Slams since Wimbledon in 2017.