An American surfer has survived a crocodile attack in Costa Rica after his friend fought off the reptile with his bare hands, according to emergency workers.

The man was in a serious but stable condition after he was attacked by a large crocodile at a popular tourist beach on Friday.

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

“He was bitten several times in the leg as well as the head,” McNulty told 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.”

McNulty said the victim remained lucid after the attack and was taken to Liberia, the provincial capital, where he underwent surgery. McNulty 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,” 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 and most of his calf muscle was stripped.

McNulty declined to identify him publicly by name but described him as a surfer from Colorado who maintains a residence in the village. Family members were travelling to be with him, McNulty added.

The US Embassy in Costa Rica said in a statement that it was aware of the case and that consular officers help US citizens when they are injured overseas, but declined to comment further citing privacy considerations.

Earlier, Costa Rican press reports had said the man was from Arizona.

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

McNulty said a few months ago there was a “minor incident” involving a smaller crocodile. “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.”