Israel Ticas is racing down the highway, drumming his hands on the wheel of “The Beast”, a tall, boxy police truck that he aims at the small, bustling town of San Luis Talpa, about 25 miles south of El Salvador’s capital, San Salvador.

A decades-long veteran of the security forces, Ticas’s first job was as an artist in the counter-terrorism unit, sketching suspected guerillas during the country’s 1979–1992 civil war. The experience left him equally as distrustful of the rightwing generals he had served as of the guerrilla commanders who would join them among the political elite at war’s end. In most ways, the country has never quite recovered since. In 2015, homicides in El Salvador rivalled the most violent peak of the civil war, and it ranks consistently among the world’s most violent nations. Before long, Ticas spots a body by the roadside. “It’s fresh,” he observes. “With clothes on.” It hasn’t been stripped or dismembered. The victim, he says, was likely shot at that spot during the night.

Ticas calls himself a “lawyer for the dead”. A self-taught forensic criminologist, he locates and digs up the bodies of victims of gang killings, and in so doing, he documents the crimes of the country’s notorious maras, or gangs. On this hot March morning in 2018, his finger is wrapped thick with gauze – a few days earlier, he pricked it on a thorn covered in fluids from decomposing bodies. His belt is adorned with a skull-and-crossbones pattern. As always, he carries a pistol in a handbag at his side.

How the US helped create El Salvador’s bloody gang war – podcast Read more

But we aren’t here for the body by the roadside. Instead, we stop outside a two-storey concrete building where men in blue-and-white camouflage uniforms armed with assault rifles are milling about. Our security detail piles into a Toyota Hilux, and we follow them zig-zagging out of town and into the surrounding sugar cane fields, the convoy kicking up a bright cloud of swirling dust. Our destination is a site used by members of the local MS-13 gang to rape, torture and execute people. The victims include civilians, rivals from the Barrio 18 gang, and their own members who break internal codes of discipline. After a few minutes, the convoy stops at a parched basin beside the fields, a spot where a river runs during the wetter months.

As the river rises and falls in the jungle terrain, Ticas explains, the land swells and crumbles. So the topography has changed since the site was in use, several years ago, and his informant has struggled to remember where all the bodies are buried. Still, Ticas has managed to find 11 of the 21 bodies his informant says are buried here. The attorney general gave Ticas three months to work the location, and today is the deadline. He thinks he can find one more before his time is up and he has brought the informant here to help.

Ticas’s informant is a lanky young man who wears a balaclava to hide his face. The night of the murder was his initiation, when he received a call and was summoned to the site. When he arrived, he was told to dig a hole: a woman would be killed. The woman and her partner had recently moved to town, and the gang suspected the couple had problems with MS-13 elsewhere. After an “investigation”, the gang “disappeared” her partner. Grief-stricken, the woman confronted them, screaming at them in the street, threatening to tell the police. They decided to kill her as well. A civilian was instructed to get the woman drunk in her home, just up the road from the burial site. Then she would be brought to the informant. His job, the informant was told, would be to cut off her head – “to prove you have balls”. But one of the gang members rushed the job and struck her in the back of the head with a machete. She wandered around the house in a stupor, like a zombie, smearing her blood on the walls. So he struck her again. And again. And again.

Ticas asks him if the victim died in her house or whether they finished her off at the burial ground. “She was in agony,” the informant says, but not dead. They removed her clothes and dragged her here, then began to chop her up.

Facebook Twitter Pinterest Israel Ticas in his office, standing in front of images of his team members at work and a map of El Salvador marking points of reported violent crimes. Photograph: Esteban Félix/AP

Ticas and his team shovel out the topsoil until they reach hard-packed earth, then sweep away the dust with brooms. He surveys the crust, looking for a patch of discoloured soil, a sign that something has been altered. With his fingers he traces the boundaries of what he sees in the dirt. His men dig down a layer around its perimeter, then level the ground flat. He draws the outline again and they dig a layer deeper. Gradually, an oval silhouette appears, the result of soil that has been dug up, oxygenated and repacked. Ticas works the site laterally, instructing his men to dig a trench beside the cavity. They sift the dirt they extract, looking for any clues the perpetrators or the victim might have left behind.

Ticas moves around the grave in a dizzying pattern, fishing out roots and rocks, working his way around the hole as if he is playing pool. The cavity is roughly the shape of the African continent. In the lower right corner, about where Tanzania might be, is a fist-sized hole. He reaches elbow-deep into it and feels what he knows by touch to be a human pelvic bone. It most likely belonged to a woman. The hole was formed by the decomposition of the fleshy mass around her hips. Over several hours, he combs away the dirt, exposing a human skeleton. Its head is bent backward, as if in supplication.

“It’s weird,” says the informant. He was sure they had buried her deeper. The limbs seem largely intact, with bits of tattered clothing around them. Ticas clears away dirt from the skull. He uses a turkey baster to clean the scalp, then fishes out broken shards from its face. “Talk to me,” he mutters to the bones. “What do you want to tell me?” After reconstructing her neck, vertebra by vertebra, Ticas gathers her ribs into a pile by the spine. He notes the slash marks on her breastbone.

Something else is amiss. The informant’s victim would have suffered machete wounds to the back of the head, but this cranium is intact. Instead, the front of the skull shows signs of being hacked repeatedly. Ticas concludes that it belongs to a different woman altogether – a name that was not on the informant’s list. It is the third body they have found here that the informant knew nothing about.

Get the Guardian’s award-winning long reads sent direct to you every Saturday morning

“We haven’t even found a quarter of the fucked-up things these assholes have done,” says a member of the police crew keeping watch over Ticas and his team. He, too, wears a mask, with an assault rifle slung over his shoulder, in case the gang’s spotters are watching. Lately, the gang has been disappearing off-duty members of the police and military and their families.

The murders that occurred here happened in the middle of a truce that the government negotiated between the rival gangs, which was credited with halving the homicide rate. But the reality, the informant says, is that it taught them to hide their victims in clandestine graves such as these. Ticas was not formally trained in forensics, and many of the techniques he uses he discovered himself. But he is not the only one learning in the process.

First, he noticed that the gangs had begun dismembering corpses so they would fit into smaller holes, making them tougher to spot. Later, they began stabbing the corpses in the stomach and throat before burying them in order to release gases trapped inside, so the decomposition process would leave an even smaller cavity. As they worked to cover up their crimes with increasing sophistication, they even joked that they were making it a challenge for Ticas, the informant tells him.

The informant had lived in the US for a decade when, in 2013, he was suddenly deported after missing a court appointment, he says. As soon as he arrived at his family’s house in El Salvador, members of MS-13 showed up at his doorstep. Everyone here must collaborate, they told him. He started as a lookout, but before long they said he knew too much about them and would have to join the gang. Today, at 24, he has already committed 31 murders, he claims. His manner is earnest and agreeable. But Ticas tells me the informant would just as soon murder us all. “We have a working relationship,” Ticas says. “But he’s a psychopath.”

A few months earlier, the informant fell out of favour. His first offence was unauthorised drinking – members have to ask for permission before consuming alcohol, since intoxication renders them unreliable. Then shortly after, he survived a police ambush. The gang assumed he was a collaborator, and they tried to kill him, though he survived again. So he went to the police and said he could give them information on 20 murders. So far, 105 arrests have been made because of his cooperation.

Facebook Twitter Pinterest Donald Trump delivering his first State of the Union address in 2018, during which he mentioned MS-13. Photograph: Pool/Reuters

In addition to revealing where the bodies are buried, the informant must name names and testify against his former associates. Unlike in the US, where he would probably be offered witness protection, in El Salvador he lives on his own, even though the gang would like nothing more than to find and kill him, which they will likely succeed in doing if he doesn’t leave the country when the case is finished.

Ticas says the gangs appreciate his efforts: some day it could be their mothers to whom he gives closure. But it’s not hard to imagine his work putting him in their crosshairs. In one scene in The Engineer, a documentary about Ticas, a gang member says that if they ever catch him offguard, they will bury him in one of the graves he has been excavating.

But for now, today was a good day. Ticas even thinks he knows the identity of the victim they have found. At the start of this case, the daughter of a missing woman came to him asking for his help. “Have faith,” he told her. “God will help me find your mother.” Each corpse that goes undiscovered is another family that will never get closure. “It’s days like this that I know that God does miracles,” he says.

The story of El Salvador’s gang problem is a study in shortsighted thinking – from governments in Washington and San Salvador, on both sides of the political spectrum – that has backfired disastrously. In his first State of the Union address, President Donald Trump railed against “the savage gang MS-13”, and called on Congress “to finally close the deadly loopholes that have allowed MS-13, and other criminals, to break into our country.”

The gang is the president’s favourite public menace to invoke in his bid to convince US voters that illegal immigration constitutes an urgent crisis and a threat to national security (second only, perhaps, to an “invasion” of migrants in caravans seeking asylum in the US – a great many of whom, ironically, are trying to flee the gang’s reach).

Rather than a problem to be deported away, however, the reality of the gang is considerably more complex. Born out of the ecology of Los Angeles’s fierce gang warfare, MS-13 was founded in the 1980s by Salvadoran refugees who had been hardened in a brutal civil war still raging at home. In time, the gang expanded to include other nationalities, and it spread to other American cities. Today, in the US, it numbers no more than 10,000 members and functions mostly – its penchant for sensational violence aside – like an average American street gang, fighting to control neighborhood turf and local drug sales.

In the late 90s, the Latino gangs of LA found an export mechanism: in response to MS-13’s growing clout and amid Bill Clinton’s immigration crackdown, the US began deporting foreign-born residents convicted of wide-ranging crimes. Thousands of convicts were sent back to the Northern Triangle each year – the neighboring Central American countries of El Salvador, Honduras and Guatemala. Among them were members of MS-13 and their LA rivals, the Eighteenth Street gang, or Barrio 18. In a region reeling from endemic poverty, wars and political violence, the struggle for survival and dominance of these Americanised gangsters produced a sociological phenomenon.

El Salvador had small, disorganised neighbourhood gangs before. But, according to a popular view in El Salvador, these mass deportations changed everything in the country. Many have come to believe that the US got rid of its problem at El Salvador’s expense. The state’s institutions had been gutted by conflict, poverty and corruption. The deportees came back from the streets of LA with tattoos and baggy clothes and brought along with them gang culture, urban warfare tactics and criminal networks from prison. The Salvadoran youths, a generation of jobless foot soldiers who made easy recruits, flocked to their banner. The maras have since drawn three generations into an escalating cycle of conflict that offers no easy escape. Today, the countries of the Northern Triangle, where the maras predominate, rank among the world’s highest murder rates and account for 75% of the migrants arriving at the southern US border. The maras, in this analysis, are the primary and most urgent problem facing countries such as El Salvador.

El Salvador’s government and its law enforcement have been quick to support this view. According to Salvadoran government numbers, there are 60,000 gang members and some 10% of the population are dependent on or otherwise tied to the gangs – in a country of just over 6 million.

It is not difficult to understand why the authorities are eager to depict El Salvador’s violence as the original sin. Doing so has allowed the Salvadoran regime to blame the cause not only on a gang culture imported from the US, but on often simplified notions of crime that have little to do with difficult and costly political solutions. Making the gangs the focus of the country’s troubles allows the government to put off engaging with more urgent and deep-seated problems such as corruption, lack of state institutions and inequality. Politicians have, to much fanfare, introduced violent and repressive anti-gang measures, often prior to key elections. But evidence suggests that the gangs’ power has only grown as a result. The maras, so goes the conventional wisdom, are a crime problem, best countered with severe police and even military force.

Facebook Twitter Pinterest Israel Ticas taking photographs of the remains of an unidentified woman in Colon, 20km west of San Salvador. Photograph: AFP via Getty

The reality is more complicated. The country’s violence is not only the result of American-imported crime. It was always determined by the legacy of El Salvador’s civil war and the underlying inequality that had precipitated it, but was never resolved by its outcome. For both of these factors, the US indeed bore considerable responsibility. But neither would be remedied alone by police killing of mareros or the mass imprisonment of gang members. If anything, US assistance to Salvadoran regimes to help tackle root problems that had been exacerbated by the war and its aftermath were in order. Successive Salvadoran governments, with US support, have done little, if anything, to address these issues – and have more often made these problems worse.

The maras will not simply be killed off or arrested away. Neither will the consequences of their continuing evolution be walled off behind national boundaries, increasingly intertwined as they are with the currents of illicit supply and demand that tie producers to the US, the world’s largest market for illegal drugs. As US-led interdiction efforts in Mexico, Colombia and the Caribbean have pushed trafficking routes into Central America – now the transit corridor for an estimated 88% of US-bound cocaine – the maras have come into closer contact with brutal Mexican trafficking organisations such as the Sinaloa cartel and the Zetas, for whom they work as contractors and hired guns.

Meanwhile, behind the noisy spectacle of family separations and the deployment of the US military to its southern border, the Trump administration has quietly enacted a wide range of calibrated policy changes to dramatically ramp up the deportation machinery it inherited, and to choke off immigration across the board. To name just a few: the US has removed domestic violence or persecution by gangs – conjoined crises in the region – as grounds for asylum in the US. It has ended the “temporary protected status” that has allowed hundreds of thousands of Central Americans to remain in the US legally for years.

El Salvador is one of the countries that is most dependent on remittances from abroad, and the fate of some 200,000 of its citizens now hangs before US courts as they decide whether Trump has the authority to revoke their legal status. Most extraordinarily of all, the Trump administration signed agreements last year with El Salvador, Guatemala and Honduras that require US-bound migrants who pass through these countries to apply for asylum there first (and allowing the US to send back anyone who failed to do so). In effect, this could make it virtually impossible for Central Americans to seek asylum in the US.

The human toll of all these changes will be devastating. Of those affected, many will remain in the US, working and living in the shadows. Others will be forced back to the countries of their birth and will meet violent ends. Many more will return, both clients and cargo of the human-smuggling networks now controlled by organised crime. If history is a guide, the gangs will only emerge stronger as a result.

• Adapted from State of War: MS-13 and El Salvador’s World of Violence by William Wheeler, published on 14 January by Columbia Global Reports

• Follow the Long Read on Twitter at @gdnlongread, and sign up to the long read weekly email here.