The Scot has often played well below his best in the tight surroundings of the tournament's second court and it was the same here as he was given a torrid time by Argentinian Mayer before digging out a 7-5 6-1 3-6 6-1 victory.
After losing the third set, it looked like it could be very uncomfortable indeed for Murray, but he eventually pulled away to set up a last-32 meeting with another Mayer, Germany's Florian.
The defending champion said: "It was a very tough match. We both ran a lot and it was very humid, I'm glad I managed to fight through in the fourth set.
"I was serving a little better as the match went on. He's a big hitter, I had to defend a lot. I think he played some really good tennis. It made for an entertaining match. He's had quite a few injuries the last few years, he's a very tough player."
Murray may wonder what he has done to upset tournament organisers after following up his late-night start on Wednesday with a trip to his least favourite major court.
He is the first of the big four men to leave the wide open spaces of Arthur Ashe, with Armstrong the scene of his most recent early grand slam loss here in 2010 to Stanislas Wawrinka, while he has struggled against Robin Haase, Feliciano Lopez and Marin Cilic over the past two years.
Mayer was born on the same day as Murray but their tennis careers have been very different, and at 81 in the rankings the Argentinian was not expected to pose too much danger to the third seed.
Murray was wary of the 26-year-old, though, and in the first game it was easy to see why.
Playing with power and freedom, Mayer brought up two break points, but Murray saved them with good serves.
As play finished on Ashe, fans decamped to Armstrong and after the first change of ends it was virtually full.
A sluggish Murray had his work cut out to hold off Mayer, and it was certainly the Argentinian who was doing most of the attacking.
Murray had one chance to break in the eighth game but Mayer powered away a forehand and levelled at 4-4.
Time and again the Argentinian came up with inventive shots to win points, but he undid all his hard work with a shocking game at 5-6. Three errors handed Murray a trio of set points, and a fourth gave it to him on the first opportunity.
Mayer's dip continued in the second set, with Murray now looking more comfortable and sprightly, and he looked on course for a comfortable victory.
But there was a twist at the start of the third when the Scot found himself in trouble at 0-40 in the second game, and Mayer took his third chance with a drilled off forehand.
The Argentinian's forehand had been the most impressive shot in the opening set, and the unexpected lift put an extra bit of zip back in it.
Murray was chuntering away to himself, and he was nearly 5-1 down but this time clawed his way back from 0-40 to hold.
He was still well in the set, and in the next game it was Mayer under pressure, but the Argentinian impressively withstood two break points to leave himself one game away from the set, which he served out with aplomb.
The crowd, keen to see a dramatic finish and impressed by Mayer's fortitude, were right behind the world number 81, who headed off for a change of clothes before the start of the fourth set.
Murray was almost overwhelmed with frustration and roared as a glimpse of an opening in the second game disappeared into the net.
But the break did come two games later, to love, with Murray letting out a huge yell of 'come on' as Mayer's backhand flew out.
That proved to be the crucial moment, with Mayer failing to win another game as Murray clinched victory in two hours and 41 minutes.