An American surfer survived a fierce crocodile attack at a popular Costa Rican beach, thanks to the brave actions of his roommate.

Jon Becker, a 59-year-old retiree from Colorado, was crossing a river at Tamarindo Beach with a friend after a morning surf on Friday when the large crocodile bit him several times in the leg and the head.

The friend, later identified only by his first name as Edgar ― Becker’s roommate ― fought off the croc with his bare hands, The Associated Press reported.

“His friend saved his life and then we the lifeguards helped keep him alive,” Pat McNulty, a Tamarindo lifeguard who was on the beach during the attack, told AP.

Once Becker was freed from the crocodile, lifeguards brought Becker back to the beach, where emergency responders administered first aid and secured a tourniquet over his wound before taking him to a hospital.

Warning: The images in the link below are extremely graphic.

Becker had minor injuries to his face, but part of his right leg was amputated, according to Costa Rican English language newspaper The Tico Times. He was reported in stable but serious condition.

Becker has residences in both Boulder, Colorado, and Costa Rica, The Boulder Daily Camera reported.

Diane Israel, Becker’s sister-in-law, told the Daily Camera that Becker is an environmentalist and had been campaigning in Costa Rica for people to stop feeding local crocodiles.

Local photographer Rafael Laurent was on the beach at the time and captured the below photo as Becker was being rescued, according to news site QCosta Rica.

The estuary that Becker was crossing is a part of the Las Baulas National Marine Park, an area protected by environmental regulations that prohibit the removal of crocodiles without a study, according to The Tico Times. Tamarindo Beach is one of the country’s most popular beach destinations.

The attack is the third and most severe crocodile attack on a surfer in that area in three years.

Tourism and wildlife officials met with police shortly after the attack to consider possible crocodile-relocation strategies, the AP reported.

Conservation officials have recently observed an increase in large reptiles in the area and have urged Tamarindo visitors and residents to give the crocodiles space.

This article has been updated to include a photo of Becker being rescued.