SAN SALVADOR — They were given one of the most dangerous tasks in policing: Take down MS-13.

They were bankrolled by the United States and trained by FBI agents. But members of the Salvadoran police have been killed by the dozens in each of the past three years, most in attacks that investigators and experts blame on MS-13, an international street gang. At least nine officers were killed in the first month of this year.

Now, a number of El Salvador’s police officers are fleeing the gang they were tasked with eliminating.

There is no list in either El Salvador or the United States of Salvadoran police officers who have fled the country. But The Washington Post has identified 15 officers in the process of being resettled as refugees by the United Nations and six officers who have either recently received asylum or have scheduled asylum hearings in U.S. immigration courts. In WhatsApp groups, police officers have begun discussing the possibility of a migrant caravan composed entirely of Salvadoran police — a caravana policial, the officers call it.

The exodus of Salvadoran police points to how the country’s security forces have failed to break the stranglehold of organized crime. It also shows that among those seeking refuge in the United States during the Trump administration are some of America’s closest security partners.

“These are among the most vulnerable people in El Salvador,” said Julio Buendía, the director of migration at Cáritas El Salvador, a nonprofit organization that works with the United States and United Nations on refugee resettlement.

The United States has been bolstering the Salvadoran police, part of a regional strategy intended to stabilize Central America’s most violent countries and reduce migration. The State Department spent at least $48 million to train police in El Salvador, Guatemala and Honduras from 2014 through 2017, according to the Government Accountability Office.

The department opened a law enforcement training academy in San Salvador, where 855 Salvadoran officers were trained by the FBI and other American law enforcement agencies in those four years.

“The Salvadoran government, with U.S. government support, has made significant gains in the area of security, including reductions in homicides and every other category of violent crime measured,” the State Department said in a statement issued in response to an inquiry by The Post.

Citing “privacy reasons,” the department would not comment on whether it was receiving asylum or refugee applications from Salvadoran police officers.

By some measures, the U.S.-backed security efforts appeared to be showing results. In 2018, El Salvador’s murder rate was 50.3 per 100,000 inhabitants. That was still among the highest in the world, but it was down from 60.8 per 100,000 in 2017 and 81 per 100,000 in 2016.

MS-13 was born in Los Angeles in the late 1970s, expanding as more Salvadorans arrived in the United States after fleeing the country’s civil war. The group splintered, with Barrio 18 becoming a chief rival, and both groups grew in American prisons before reaching El Salvador through mass deportations. Between 2001 and 2010, the United States deported 40,429 ex-convicts to El Salvador, according to the Department of Homeland Security.

El Salvador’s government adopted an “iron fist” response to the gangs, including more police operations. When that approach failed, it tried to broach a truce with the gangs in 2014. The pact quickly disintegrated and was followed by another surge in violence. It was then that the gangs began to explicitly broadcast their threats against police officers.

“If you kill a ‘pig,’ or a police officer, you’re more respected in these gangs. That’s the policy — using death as exchange currency,” said Héctor Silva Ávalos, a journalist and researcher who has written a book on the Salvadoran police and has served as an expert witness at several asylum hearings for former police officers in the United States.

With salaries of $300 to $400 per month, the low-level police officers who make up the majority of the force often have no choice but to live in neighborhoods vulnerable to gangs. And so, in the vast majority of the cases, police officers are killed when they are home from work or are on leave.

In August, Manuel de Jesús Mira Díaz was killed while buying construction materials. In July, Juan de Jesús Morales Alvarado was killed while walking with his 7-year-old son on the way to school. In November, Barrera Mayén was killed after taking leave to spend time at home with his family.

The police investigated a number of the killings since 2014 and found members of the major gangs responsible.

“They have more control than we do. When we go home, we’re in neighborhoods where there’s one police to 100 gang members. We’re easy victims,” said one officer in the country’s anti-gang unit, who, after being threatened by MS-13 in his home, is awaiting refugee status from the United Nations. He spoke on the condition of anonymity out of fear for his safety.

Police arrested a 26-year-old man, who they said is an MS-13 member, after he fatally shot an alleged rival gang member Feb. 3 in Queens.

Complicating their response to the threats, Salvadoran police are also not legally allowed to take their weapons home with them.

“I bring it home anyway. I sleep with it on my waist,” said a female officer, who is awaiting refugee status from the United Nations and spoke on the condition of anonymity out of fear for her safety. “My husband and I take turns sleeping. We know they are going to come for us.”

Many units in the Salvadoran police are forbidden to wear balaclavas to conceal their identities. In anti-gang units, officers are allowed to wear such masks during operations, but they are frequently asked to testify in court, where they must show their faces and identify themselves by name while gang members look on.

In 2017, El Salvador’s attorney general, Douglas Meléndez, urged the government to do more to protect off-duty police, asking the parliament to pass a “protection law” for police and soldiers that would also provide funding to protect their families. The law was never passed.

Last month, security concerns played a central role in a presidential election won by San Salvador’s 37-year-old former mayor, Nayib Bukele. At least 285 people were killed in January, leading up to the vote, which many saw as the gangs’ attempt to leverage their influence amid the election campaign. In a security plan leaked to the Salvadoran news media, Bukele’s campaign wrote: “The expansion of these criminal groups is undeniable, as is the impact on the lives of ordinary citizens.”

In response to the targeting of police officers this year, El Salvador’s police chief introduced a policy: For their own protection, officers were not allowed to return to their homes. The police chief declined multiple interview requests.

Many officers, feeling unprotected by their own force, have said their only option is to leave the country.

Organizations that work with the United Nations to resettle Salvadoran refugees in the United States say they have found more and more police officers arriving unannounced at their offices. In addition to the 21 asylum seekers and refugees identified by The Post, several others have recently arrived in Spain and Mexico, according to news reports, applying for humanitarian visas or other forms of protection. Lawyers for police officers and many officers themselves say that far more officers are preparing to flee.

One of the cases that Buendía, the migration director of Cáritas, referred to the United Nations High Commissioner for Refugees is an officer who survived two attacks while off duty. First, he was shot eight times by suspected gang members; then, two years later, he was shot four times. The officer pleaded for protection from his commander.

Buendía included a letter from the commander in the officer’s refugee application. “There’s nothing we can do for you,” the commander wrote. “You need to protect yourself.”

A police spokesman declined to comment on the letter.

In one case, concerning a police officer now applying for asylum in U.S. immigration courts, gang members threatened to kidnap the officer’s child at an elementary school in rural El Salvador.

“That’s not what these guys signed up for. It’s one thing to be shot at on the job. It’s another for your family to be targeted while you’re off duty,” said Emily Smith, the attorney representing the officer.

Lawyers such as Smith who are representing the officers typically try to explain to immigration judges that as former police officers, their clients would be persecuted if they were forced to return to El Salvador. But the attorneys are also aware of how narrowly U.S. asylum law can be applied, and that the courts are unlikely to grant asylum to all former officers.

“What we chose to do is focus on the specific threats facing our client,” said Patrick Courtney, who last year represented a Salvadoran officer who had been physically assaulted in his home before fleeing. “We focused on his anti-gang views, on the fact that the threats were directed at him individually.”

Courtney’s client was granted asylum late last year. They discussed where he would live in the United States, and what he would do next. The former officer had only one goal: He wanted to join the United States military.