The host nation needed to win all three rubbers in straight sets to snatch a final spot off the unbeaten Spanish pairing of Maria Jose Martinez Sanchez and Tommy Robredo.
But the Scot responded well, winning the third set 6-2 in just 33 minutes before surviving another tie break to win through in four sets in three hours and 27 minutes.
The result won't always conform with a sense of how close the matches were: A winner of a five-setter in which he dropped two sets in tiebreakers and won the other threesets 6-0 probably would have a higher dominance ratio than a straight-sets win in which each set was decided by a tiebreaker.