Second seed Schwartzman, who struggled to find his serving rhythm and recorded eight double faults, fell short at the quarter-finals stage in Hamburg for a second consecutive year.
Mayer will next meet Slovakian qualifier Jozef Kovalik, who fended off Brazilian Thiago Monteiro 3-6 6-3 6-2 earlier in the day.
Top seed Dominic Thiem's bid for a third claycourt title of the season came to a halt after he suffered a shock 7-6(5) 7-6(7) defeat by Chilean power-hitter Nicolas Jarry.
Young firebrand Jarry's incredible tally of 35 winners came at a cost of 51 unforced errors but it was his ability to claim points under high-pressure situations that proved decisive in two intense tiebreaks.
Jarry, ranked 69 in the world, saved three set points in the second set tiebreak before closing out his first victory over a top-10 opponent.
(Reporting by Hardik Vyas in Bengaluru; Editing by Christian Radnedge)
