Authorities in Central American country have been rounding up suspected gang members since March, following the killing of 87 people in gang-related violence.
El Salvador has arrested nearly 42,000 suspected gang members since President Nayib Bukele launched a "war" in March on criminal groups terrorising the country, the attorney general said.
"The last count ... reflected about 41,846 arrests," Attorney General Rodolfo Delgado told state TV on Thursday.
Bukele announced a state of emergency following a bloody weekend in which 87 people were killed in gang-related violence.
Since then, the police and military have been rounding up suspected gang members using emergency powers that have done away with the need for arrest warrants.
The small Central American country has also increased sentences for gang membership five-fold, to up to 45 years.
But rights groups have denounced the arbitrary arrest of many people, including minors, with no gang links.
Over 8,500 have been brought before a court, of whom 456 were freed after their first hearing for a lack of evidence, Delgado said.
Another 33,258 are being held in "provisional detention" for an initial period of six months, which may be extended.
The wave of detentions is unprecedented in the country of 6.5 million people that has suffered decades of violent crime driven by powerful gangs such as Mara Salvatrucha (MS-13) and Barrio 18.
These gangs count some 70,000 members, most of them now behind bars, according to the authorities.