Novak Djokovic, his main rival for the US Open title, had benefited from a walkover Wednesday, and Murray looked to get his business done quickly against a tricky opponent in Marcel Granollers.
The world No. 2 was seemingly racing toward the third round when he went 5-2 up in the first set. But a 10-minute long service game and three missed set points later, Murray was broken by the Spaniard.
The next game went even longer and Murray eventually took his seventh set point after 67 minutes. From there, the 2012 champion raced through the second set and closed out a 6-4, 6-1, 6-4 win in two hours, 23 minutes.
"It was tough -- had it gone to five-all then the first set becomes a really tough one and all the pressure is on me having led 5-2 and had bunch of set points," Murray told ESPN tennis analyst Brad Gilbert on court.
"Thankfully I got through the 5-4 game and the momentum was back with me. He made it tough for me, he's very good with hands. I'm glad to get through it in three sets."
Murray got just 43 percent of his first serves in play and made 28 unforced errors, but he hit 34 winners and won 65 percent of points on his second serve.
"I hit quite a lot of winners, although my first-serve percentage wasn't great," he added. "I won a lot of points behind my second serve. That's been good the first two rounds. It's a little bit different serving under the roof, a little bit heavier conditions."
It was an efficient enough performance from Murray. Djokovic, dealing with a wrist injury, is a slight favorite with the bookmakers, but the British No. 1 is 24-1 since reuniting with coach Ivan Lendl.
He has reached seven straight finals since the Madrid Masters in May and is bidding to become the fourth man in the Open Era to play four major finals in a calendar year.
American qualifier Jared Donaldsonhad never won a Grand Slam match before arriving in New York -- now he is into thethird round here.
The 19-year-old, currently ranked No. 122, beatViktor Troicki 7-5, 6-3, 6-3 on Thursday to follow up on his shock four-set win overDavid Goffin in the first round.
A loser in the first round at Flushing Meadows the past two years, Johnson said: "I'm still 120 in the world. I want to be top 10, top 5, No. 1."
Juan Martin del Potro, the 2009 champion ranked 142nd after three left wrist surgeries, reached the third round here for the first time since 2012 witha7-6 (5), 6-3, 6-2 win over19th-seeded American Steve Johnson.
Kei Nishikori seized the momentum after a rain delay that lasted more than two hours to beat 20-year-old qualifier Karen Khachanov 6-4, 4-6, 6-4, 6-3 on Thursday. When rain halted action, the players had split the first two sets and were tied at 4-4 in the third.
Britain's Daniel Evans saw off Germany's Alexander Zverev in four sets to reach the third round of the US Open.
The 26-year-old matched his best run at a Grand Slam with the 6-4, 6-4, 5-7, 6-2 victory over the highly-rated teenager, having also progressed to the same stage here in 2013 and at Wimbledon earlier this summer.
Murray moving great in win over Granollers
Andy Murray defeats Marcel Granollers 6-4, 6-1, 6-4 to advance to the third round at the US Open.