Montgomery County has prosecuted about 1,000 gang members in the last two years, up from 77 gang-related prosecutions in 2006, officials said Tuesday.

Elected officials credit the surge to recent efforts to fight gangs in an affluent county that ignored its gang problem for many years.

“Four or five years ago ... I think there was a level of denial about gang-related activity in the county,” said State’s Attorney John McCarthy, who created an anti-gang task force in 2007. “I think we’re beyond that now.”

The crackdown came about two years after Northern Virginia started fighting the growing plague in 2005.

The Northern Virginia Gang Task Force said last week that gang-related crime in Fairfax County has dropped by 15 percent in the last four years.

The unit is traditionally stingy when it comes to crime statistics and doesn’t pursue every gang-related crime. But officials said gang-related arrests in the five counties it covers dropped from 590 in 2006 to 294 last year.

National gangs are relatively new to the Washington area, although their numbers are rising, experts say. In the last two years, the Los Angeles-based Bloods has doubled its numbers in Montgomery and Prince George’s counties and the District of Columbia as it spreads from Maryland’s prisons.

In December, a group of five Prince George’s Bloods members opened fire on MS-13 members outside the Westfield Wheaton mall.

An MS-13 member was injured, and the five Bloods were arrested days later.

Jon Feere, who studies Washington-area gangs for the Center for Immigration Studies, said the high-profile crackdown on illegal immigrants in Prince William County and other Virginia jurisdictions has Hispanic gang members spilling onto more friendly territory in Maryland. Many have gone to Montgomery County, where illegal immigrants feel safe, Feere said.

Montgomery County lawmakers recently have pushed back. In January, County Executive Ike Leggett changed the rules regarding federal checks of those arrested. Now, suspects accused of committing certain violent crimes have their names run through a federal immigration database.

That change came after a spate of high-profile violent crimes allegedly committed by illegal immigrants, many with ties to gangs such as MS-13. In April, accused illegal immigrant and MS-13 member Hector Mauricio Hernandez pleaded guilty to shooting 14-year-old Montgomery Blair student Tai Lam to death on a bus.

Law enforcement officials estimate that the county has about 40 active gangs and 1,150 active gang members, with violent crimes against rival gangs, particularly Hispanic groups, increasing.

McCarthy said his office was prosecuting known gang members for any type of crime, from alcohol violations to assaults, leading to the increase in prosecutions the last several years. The approach allows the county to get longer prison sentences and keep better tabs on gangs’ activities, he said.

However, he said the number of gangs and gang-related crimes has remained about the same.

Officials said that gang-related crimes account for less than 5 percent of the county’s crime rate. But, they added, gangs are “disproportionately” affecting the quality of life in certain neighborhoods, including parts of Montgomery Village, Wheaton and East Silver Spring.