A Costa Rican court has sentenced four men to decades in prison for the 2013 murder of an environmentalist, tying up four western female volunteers who were with him, and separately raping a Costa Rican woman.

The judgment capped a nine-week retrial of seven men accused of killing Jairo Mora, a 26-year-old Costa Rican working to protect sea turtle nests on the country’s Caribbean coast.

The court in the eastern coastal city of Limón found four of the men – Hector Cash, Ernesto Centeno, Brayan Quesada and Donal Salmon – guilty of murder, illegal detention, sexual assault and aggravated robbery.

It handed down terms of 74 to 90 years for each of the four convicted men, but under Costa Rican law the lengthy sentences automatically revert to a maximum of 50 years each.

The three other men accused in the trial were acquitted.

The attack on Mora and the female volunteers with him – three Americans and a Spaniard – occurred on Moin Beach, just to the north of Limon, on 31 May 2013. The savagery of the attack dealt a severe blow to the Central American country’s image as a safe, eco-tourist-friendly destination.

Prosecutors said the convicted men were part of a turtle-egg poaching gang who grabbed Mora. They beat him unconscious, tied him to a pickup truck and dragged him along the beach until he suffocated in the sand.

They were acquitted on a charge of raping one of the four female volunteers, but were convicted and sentenced for holding the women for hours and robbing them. They were also sentenced for attacking a local Costa Rican family in the area around the same time, raping a woman and robbing them.

The retrial was ordered by an appeals court after the seven suspects were acquitted in a trial early last year because of police errors in handling the investigation.

• This article was amended on 31 March 2016. An earlier version said incorrectly that the four men convicted of murder had also been convicted of raping the four western women.