An American surfer was in serious but stable condition after he was attacked by a large crocodile at a popular tourist beach in Costa Rica.

A witness said a friend saved the surfer's life by fighting off the reptile with his bare hands.

Pat McNulty, who works as a consultant and is a certified trained lifeguard in Tamarindo, a north-western town popular with surfers and eco-tourists, said the man was crossing a river with the friend when the crocodile struck.

"It was a vicious attack, and he was bitten several times in the leg as well as the head," Mr McNulty told The Associated Press by phone from Costa Rica.

"They were able to get him free, swim him to safety and then trained lifeguards responded ... and we administered first aid and called an ambulance."

Mr McNulty said he accompanied the victim, who remained lucid after the attack, to Liberia, the provincial capital, where he underwent surgery.

He declined to give specifics about the man's injuries other than to say he suffered lower leg trauma and his condition was serious but stable.

"His friend saved his life ... and then we the lifeguards helped keep him alive," Mr McNulty said. "It was a very traumatic scene, and all individuals attending him did a tremendous job."

Costa Rican media reported that the victim suffered partial amputation of his right ankle.

Mr McNulty said he was familiar with the man before the attack because Tamarindo is a small town where everyone knows everyone else.

He described him as a surfer from Colorado who maintains a residence in the village. Family members were travelling to be with him, he added.

The US Embassy in Costa Rica said it was aware of the case and that consular officers help US citizens when they are injured overseas.

Community, wildlife and tourism officials met after Friday's attack to consider strategies for relocating crocodiles and making sure there is proper signage to keep people safe.

Mr McNulty said a few months ago there was a "minor incident" in which a smaller crocodile bit a person.

"We live in a country where there's large crocodiles, and people take for granted that when you go into a river that you're safe," the lifeguard said.

"But the fact of the matter is that you need to be aware of your environment. We're in their world."