The Scot and his Spanish partner were a wildcard entry but managed to down the second seeds 6-7 (5) 6-3 11-9 at the Rogers Cup.
The pair will next face France's Jeremy Chardy and Fabrice Martin.
Dan Evans will meet Rafael Nadal for the first time after easing his way into the second round at the same tournament.
The Briton progressed to a showdown with the top-seeded Spaniard, whom he might have faced at Wimbledon, after a straight sets victory over Australia's Alex de Minaur.
Evans took the first set 6-4 but was pushed further in the second before closing it out 7-6 (6), having saved seven of eight break points he faced in the match and converting both of those which came his way.
Kyle Edmund was not intimidated by Nick Kyrgios' recent Washington Open title, dispatching the Australian 6-3 6-4 in a rain-delayed match.
A passing shower halted the first set at 4-4, with Edmund returning to comfortably dominate Krygios and move into the next round.
In the doubles, Jamie Murray and Neal Skupski made a swift exit and they were beaten 7-5 7-5 by fellow Briton Joe Salisbury and his American partner Rajeev Ram.