The world number four was completely out of sorts in the first set but then went on to win 11 of the last 12 games as Mayer crumbled alarmingly.
Murray had never even reached the quarters here until this year but after a poor start riddled with unforced errors he found his form on his least favourite surface, finishing with twice as many winners as his opponent.
The first two sets were a poor advert for serving as eight of the 14 games ended in a break.
Murray was the principal culprit in the first set as he put up feeble resistance, going down 6-1 and holding serve only once in his first five service games.
But as erratic as the Scot was in the first set, the German was just as bad in the second, in which he failed to hold serve at all.
The second opened with three breaks of serve before Murray crucially held for only the second time in the match despite going 0-30 down.
At deuce Mayer sent a simple drop shot into the tramlines and then followed that up by going long with a forehand.
Murray seemed to accelerate from there and closed out the set 6-1 with a backhand crosscourt winner.
Mayer had completely lost his way on serve and after Murray held at the start of the decider, the German was broken for the fifth game in a row as he netted a backhand volley on the stretch.
Having found the corners at will in the first set, Mayer was now struggling to find his range.
The world number 28 held his next service game but it was a brief reprieve as at 4-1 he was broken to love after netting a forehand and Murray served out the match.
In the women's event Li Na of China was the first person into the semi-finals after completing a quick 6-3, 6-1 victory over Hungarian Greta Arn.
The fourth seed has made startlingly easy progress, losing only 13 games in three matches, and she is yet to drop a set.
- AFPTags: sport, tennis, italy