APOPA, El Salvador—The Congress of El Salvador agreed in April to extend the authority of jailers to keep gang leaders in solitary confinement. Over the next five days, the two reigning street gangs killed more than 100 people.

With the highest homicide rate of all countries in the world, El Salvador is a nation held hostage.

Law-enforcement officials estimate that one gang, MS-13, operates an extortion racket with little pressure from authorities in 248 of the 262 of the country’s municipalities. It battles for neighborhood control with another gang, Barrio 18, which runs its own protection scheme in nearly as many regions.

Politicians must ask permission of gangs to hold rallies or canvass in many neighborhoods, law-enforcement officials and prosecutors said. In San Salvador, the nation’s capital, gangs control the local distribution of consumer products, experts said, including diapers and Coca-Cola . They extort commuters, call-center employees, and restaurant and store owners. In the rural east, gangs threaten to burn sugar plantations unless farmers pay up.

They have grown so pervasive that “you don’t know where the state ends and the criminal organizations begin,” said Mauricio Ramírez Landaverde, El Salvador’s minister of justice and security, who oversees the national police force.