Seeded 29, Schwartzman recovered from a 4-6 loss in the first set against the 2014 winner to level the match by breaking serve and taking the second 7-5.
There was little to separate the players in the final two sets, but Schwartzman of Argentina, held his nerve to see out the match with two further breaks of serve, to triumph 7-5, 6-4 and secure one of his career best wins over this year's Wimbledon runner-up.
Schwartzman will take on Lucas Puille of France for a place in the quarter-finals of the grand slam tournament.