Spain clinched a 2-1 victory over Belgium in the ATP Cup quarter-finals after Rafael Nadal made up for losing his singles match.