A man whose boat capsized in the Pacific Ocean has been rescued after spending two days clinging to a foam cooler off the coast of Colombia.

Solano Salazar, 47, sailed to sea from the town of Lopez, near Guapi, with a friend to go fishing.

Strong winds overturned their boat and both men were taken with the gusts but Salazar managed to hold on to a foam box for two straight days.

"I am okay now because the navy rescued me. I thought I was going to die," Salazar told reporters. "I couldn't think about anything else."

Captain Andres Mejia, commander of Colombia's Pacific coastguard, said that Salazar was drifting holding onto a portable cooler, dehydrated but unhurt, when he was found.

"The person was rescued and taken to the Malaga hospital. He was given first aid. He was dehydrated and according to what he said, they left [port] on Friday from the Guapi area to fish with another person and they were turned over in bad weather. He drifted tied to a portable cooler," said Mejia.

Salazar has been transferred to a hospital where he is expected to make a full recovery. The search for Salazar's companion is continuing.