The 12-metre vessel, which had set sail from Portugal’s capital Lisbon, sent out a distress signal late on Monday evening from the Atlantic Ocean.
Spanish coastguards found the upturned boat, but the sea was too rough to rescue him – so the sailor had to wait until morning.
The man’s survival was “verging on the impossible”, said coastguard divers.
His boat sent a distress signal at 20:23 local time on Monday, 14 miles (22.5 km) from the Sisargas Islands, near Spain’s north-west Galicia region.
A rescue ship carrying five divers as well as three helicopters set off to find and rescue the man, who has not yet been named.
A diver was winched onto the ship’s hull to seek signs of life and the man responded by banging from inside.
The sea was rough and the sun had gone down, so the rescue team attached buoyancy balloons to the boat to stop it from sinking and waited until morning.
The next day, two divers swam under the boat to help the sailor out, who they found wearing a neoprene survival suit and submerged in water up to his knees.
The man then jumped into freezing water and swam under the boat towards the sea’s surface.
In a tweet, Spain’s Maritime Safety and Rescue Society said: “Each life saved is our biggest reward.”
Vicente Cobelo, a member of the coastguard’s special operations team, said the sailor got into the water “of his own initiative” .
But, Mr Cobelo added, divers helped pull the sailor out, as it was difficult for him to get out of his suit.
He was airlifted by the rescue team and briefly taken to hospital for checks.