Two fishermen whose boat capsized in the Gulf of Mexico survived nearly two days and nights drifting at sea before one of them climbed the leg of an offshore oil platform.

The men were rescued early Friday after drifting more than 20 miles over the course of about 40 hours, first aboard a small area of the boat's underside and then buoyed by life jackets.

Aaron Pilcher, 29, and Michael Prahm Jr., 27, embarked on their trip Wednesday morning from Freeport, 55 miles south of Houston. They motored their 23-foot-long boat to a popular fishing site about 36 miles offshore.

They noticed the boat was taking on water at about noon. The boat capsized just as they turned on the radio to try to call for help.

The men grabbed two heavy-duty life jackets and three small bottles of water as they scrambled onto the part of the boat still sticking out of the water.

Family members notified the Coast Guard Wednesday night that the men were missing.

As waves washed over them, the men watched Coast Guard helicopters and planes flying in the area, but never close enough to spot them.

The men drifted to within a half-mile of an oil platform on Thursday night and decided to leave the boat and try to swim to it.

"We thought we could make it, but a strong rip current got hold of us and carried us away," Prahm said.

When they drifted close to another rig, Prahm said he was too weak to swim to it and urged Pilcher to swim for help. Pilcher managed to climb about 15 feet up a barnacle-encrusted metal pipe.

"All I knew was that there are two things on every platform — water and a telephone," Pilcher said. "And I wanted water, and I wanted to telephone my family."

Pilcher surprised the rig's crew when he walked into the galley at about 3:30 a.m. Friday. The Coast Guard was notified, and a patrol boat found Prahm two miles away at 6 a.m.

The men were treated at a hospital Friday for sunburn, cuts and scrapes.