Bidding to beat a top-20 player at a grand slam for the first time since his hip problems began in 2017, Murray won the opening two sets before Berrettini fought back to level in a dramatic fourth-set tie-break.
The Italian 13th seed created a match point in the 10th game of the deciding set but dumped a simple backhand into the net with the court wide open and Murray held on to force a deciding tie-break.
A gruelling first point won by the Scot set the tone and Murray, who moved superbly, got the luck his performance deserved with a netcord on his first match point before celebrating a stunning 6-3 6-3 4-6 6-7 (7) 7-6 (6) victory after four hours and 49 minutes.
While such matches would have usually been contested in later rounds in his heyday, this will surely mean almost as much four years after the tearful press conference at Melbourne Park that seemed to herald the end of his career.
Murray said: “The last few years, I’ve certainly questioned myself at times. There’s certainly a lot of people who’ve questioned me and my ability, whether I could still perform at the biggest events and the biggest matches.
“I felt very proud of myself after the match. That’s not something that I generally felt over the years at the end of tennis matches.
“I think I’m proud of the work that I put in the last few months. I trained really, really hard over in Florida getting ready to play here. I’m really proud of how I fought through that match at the end when it could have got away from me, how I played in the tie-break at the end.
“I was impressed with myself, which again is not something… I’m hard on myself usually. Tonight I need to give myself some credit because the last few years have been tough.
“I’ve lost a few of those type of matches in the slams the last couple years, whether that’s the (Stefanos) Tsitsipas match (at the US Open in 2021) or (John) Isner at Wimbledon. That one could have gone the other way tonight, but I stayed strong and I deserved to win.”
The former world number one spoke ahead of the match about how much better he was feeling about his game and fitness, and it was evident from the start that this was a different Murray to the player who has scrapped for wins since returning from hip surgery in 2019.
With the roof closed due to extreme heat, Murray was right on his game from the start and took full advantage of a sluggish opening from Berrettini, who made the Wimbledon final in 2021 and the semi-finals here last year and is known as one of the toughest competitors on tour.
Had Murray converted two break points in the fourth game of the third set, he may have been off the court a lot earlier, but Berrettini held on and from there began to play much better, hammering down aces and cranking his big forehand into gear.
The fourth set was decided in a captivating tie-break, where Murray was an inch away from carving out a match point with a diving volley before Berrettini, who had tightened up horribly on two set points, freed himself to take the third.
He looked in control of the decider, his serve untouchable as the pressure gradually increased on Murray, but Berrettini missed his chance.
In the deciding tie-break, the Scot was half way to the 10 points needed before Berrettini got on the scoreboard and, although the Italian threatened to create a grandstand finish, Murray got his moment of fortune.
The players only found out just before taking the court that the roof would be on and Berrettini admitted he struggled to adapt to the different conditions.
He had won three matches in a row against Murray, including at the US Open last year, and said: “I think he played definitely better. He was moving way better, hitting the ball better… everything, in general.
“He served really well. I knew it would have been a tough first round. He loves to play these kind of matches. He’s a great champion. Personally it was great to play with that atmosphere against him. It was just a great match. Unfortunately it didn’t go my way.”