Costa Rica recorded its highest-ever annual murder rate in 2017, authorities said this week, blaming score-settling between gangs and drug trafficking for the rise.

The nation of about five million people, still considered one of the safest relative to others in Central America, saw 603 homicides last year, according to preliminary data from the police service responsible for investigating them.

That works out to a rate of 12.1 murders per 100,000 inhabitants.

The number of killings “is the highest in the history of the country,” the deputy director of the Judicial Investigation Organism, Michael Soto, said at a news conference.

Much of Latin America suffers from homicide rates higher than the world average of 5.3 per 100,000 inhabitants given by the World Bank. By comparison, the United States has a murder rate of 4.9 per 100,000 inhabitants, according to recent FBI data.

The World Health Organization considers a murder rate of more than 10 per 100,000 to be an “epidemic.”

In 2016, Costa Rica recorded 578 murders, unprecedented at the time.

Soto said 48 percent of the deaths in 2017 were from gang violence and 25 percent from drug trafficking, the latter most notably on the Caribbean coast and in the capital, San José.

Other causes were domestic violence and brawls.

Soto said the outlook for 2018 was somber.

“Since 2012 we have seen an increase and it’s likely this curve will keep going up unless something extraordinary happens,” he said. He insisted, however, that “we are not losing control, and we are at the same level as in other societies.”

Costa Rica is sandwiched between Nicaragua and Panama which, together, have relatively low crime and murder rates compared with El Salvador, Honduras and Guatemala to the north. The latter three countries, which accounted for 16,000 murders in 2016, provide the biggest source of undocumented migrants heading to the United States.