He wasn’t the man they were looking for, but he was exactly what they wanted — him and his 2,000 pounds of high-grade marijuana.

Edgar Gonzalez assumed police were looking for him during an unrelated drug raid on the first floor of his three-decker on Wilcock Street in Dorchester Wednesday and tried to flee from the back door, catching the attention of drug officers.

Police were looking for another man, but they were glad to find the ton of marijuana stashed inside his third-floor apartment — an estimated $4 million to $5 million in street worth.

“This is the single largest seizure of marijuana in recent memory,’’ Suffolk District Attorney Daniel F. Conley said yesterday. “Detectives said they hadn’t seen such a quantity in at least 20 years.’’

In court, Assistant Suffolk District Attorney Jeremy Bucci said, “Some was located in a closet, another amount was located in a side room off to the side. This is, without a doubt, a significant quantity.’’

Gonzalez was arrested a few streets away from his apartment; he denied any knowledge of the drugs. He said he lives with other people in the apartment, but that he did not know who they are. He also may have used a different name on some occasions — Felix Soto, according to police.

Gonzalez, 40, was ordered held in lieu of $1 million cash bail after his arraignment. A native of the Dominican Republic, he is also wanted for possible immigration violations by the US Immigration and Customs Enforcement, and will be referred to that agency even if he posts bail.

Prosecutors and Gonzalez’s own lawyer voiced concern yesterday that he could be in danger if he is released from jail — from envious people who want such access to drugs and money and people angered because they lost out on the drugs and money.

“With an allegation like this, there’s always a great possibility that he could become a target,’’ said his lawyer, Holly Clarke, during Gonzalez’s brief court appearance yesterday, during which he pleaded not guilty to trafficking marijuana.

“This arrest should serve as a clear message to those who attempt to disrupt the safety of our neighborhoods,’’ said Police Commissioner Edward F. Davis.

If convicted, Gonzalez could face up to 15 years in prison, with a mandatory minimum of five years.

Drug detectives with Boston police, State Police, and the FBI had shown up at the Wilcock Street three-decker to execute a search warrant related to a heroin trafficking investigation. Six locations in and around Boston were searched yesterday as part of that investigation. Eight people were arrested and officials seized heroin, a firearm, and approximately $40,000 in cash in what they called the dismantling of a significant heroin organization.

A SWAT team along with police and federal agents swarmed the Wilcock Street property, targeting the first floor, and were questioning neighbors when they spotted Gonzalez, allegedly fleeing from the top floor.

“He said he was running because he thought police were coming for him,’’ Bucci said.

Police said Gonzalez left the door to his apartment open, and they caught a strong whiff of marijuana. They secured the home and obtained a search warrant. Yesterday afternoon, they entered and found 40 bales of marijuana, wrapped tightly in plastic and secured in duct tape, in a closet and against a wall.

Authorities said a one-pound sample bag of marijuana was left in the main room. Police also reported finding scales, packaging materials, and several cellphones.

They also found paperwork in the names of other men. Gonzalez had a Dominican Republic passport with his photo but in the name of Felix Soto.

Residents along Wilcock Street, off Blue Hill Avenue at the Dorchester and Mattapan line, said yesterday that the apartment has a high turnover rate, and they did not know any of the people involved in the raids. The street has had troubles before, with shootings and stabbings in recent years.

But they did not expect the discovery of a ton of marijuana.

“This street is quiet in one way, noisy in another way, but you’d never have seen that,’’ said one neighbor, who did not want his name used because of the nature of the crime.

He added, “I’m surprised you couldn’t smell that down the street.’’

Milton Valencia can be reached at mvalencia@globe.com.

© Copyright 2010 Globe Newspaper Company.