A 19-year-old accused of murder amid rising violence in Montgomery County is an alleged MS-13 member who served less than six weeks in jail recently for carrying a loaded handgun onto a commuter bus, according to court filings.

Erick Aguilar, who was indicted along with a 17-year-old last week, is charged with firing several rounds at 25-year-old Marvin Mendoza along a residential street in Wheaton in broad daylight. As Mendoza tried to run down Blueridge Avenue, police say, Aguilar and three others chased him and fired again as he lay dying on the roadway Aug. 10.

“He was struck in the legs, he was struck in the neck, and he was struck in the chest,” prosecutor Kelly McGann said in court recently.

At the time, Aguilar was on probation after 38 days in jail for the case involving the gun on the bus, the resolution of which came after a plea agreement that underscores the tension seen daily in criminal prosecutions across the country: How much punishment should a person receive if they illegally possessed a gun but didn’t point it or fire it at anyone?

“It’s inexcusable that he was out of jail that quickly,” said retired Takoma Park police chief Alan Goldberg, who previously served 31 years in the Montgomery County Police Department. “This is a homicide that could have been prevented.”

Goldberg and other experienced police executives have long said that one of the most effective ways to curb gun violence is to find illegal guns before they are used. Significant punishment, they say, is a necessary deterrent.

“They have to know there are consequences,” Goldberg said.

Allen Wolf, the chief public defender in Montgomery County, whose attorneys represented Aguilar earlier this year, noted that he did pay a price: 38 days behind bars after his arrest, followed by an additional 40 days of home detention. More jail time, Wolf said, wasn’t warranted.

“This is a very typical resolution for a client pleading guilty to misdemeanor possession of a gun,” Wolf said.

Wolf said relatively few people in Montgomery County who illegally possess guns ever commit violence.

“The fact of the matter is that people go to jail usually for physical harm they’ve done to someone, not for possession crimes,” he added.

A spokeswoman for the Montgomery County State’s Attorney’s Office, Lauren DeMarco, declined to discuss details of the plea agreement, citing the prosecution against Aguilar in Mendoza’s fatal shooting and its general policy of not discussing ongoing cases. DeMarco said the earlier gun case was not gang-related, but prosecutors at the time were aware that police “had validated Aguilar as a member of MS-13.”

Aguilar “denies having anything to do” with Mendoza’s slaying, according to his attorney in the matter, Kathleen Dolan.

She questioned the strength of the investigation and noted that arrest warrants filed by detectives cite two unidentified witnesses but no physical evidence that corroborates what they say. Dolan added that based on her understanding of the case so far, the two witnesses are both gang members.

The killing was one of 26 in Montgomery County this year, compared with 17 for all of 2020, according to tallies kept by The Washington Post. This year’s total includes 20 killings by guns so far, compared with eight by guns in all of 2020.

Montgomery County Police statistics also show that aggravated assaults are up 21 percent from the same time last year, with 653 cases reported so far, according to statistics provided by police Wednesday. Robberies are up 17 percent, with 330 reported so far in 2021, compared with 283 for the same period in 2020, according to police figures.

Born in Maryland, Aguilar grew up in the Aspen Hill area of Montgomery County, according to court records. He played soccer in high school and received a high school equivalency degree, the records state. Starting in 2017, prosecutors have said in hearings, he was shown to be involved in three cases in juvenile court — for theft, misdemeanor assault and conspiracy to commit robbery, and assault.

His adult record appears to have started earlier this year. The morning of Jan. 9 — four days after his 19th birthday — Aguilar showed up at a Shell gas station in Gaithersburg “heavily intoxicated and bleeding from several lacerations all over his body,” according to arrest records. Gaithersburg Police were called and Aguilar told them he’d been jumped at a nearby Motel 6. Officers went to the motel, spoke with several people, including Aguilar, couldn’t sort it out and released everyone, according to court records.

Detectives subsequently reviewed surveillance footage from the motel that showed Aguilar “shirtless and shoeless,” leaning on a woman against a third-floor balcony railing, according to the records. She freed herself, went into a room and closed the door, prompting Aguilar to punch out a window, police alleged. They got a warrant for his arrest on charges that included assault, intoxicated endangerment and property destruction.

In early April, the Montgomery County Police Department’s Repeat Offender Unit tracked Aguilar to a commuter bus in White Oak, saw him board the bus, and stopped it, according to court documents. They boarded the bus, approached Aguilar and asked whether he had any guns or drugs.

“Both,” Aguilar allegedly said.

Police found a loaded Sig Sauer 9mm semiautomatic handgun in his waistband. They also found marijuana, a digital scale and $305 in cash, according to court records. Aguilar was charged with six gun and drug offenses and put in jail.

In court the next day, prosecutors argued that he should remain jailed on no-bond status, saying he was a “danger to the community.” Montgomery County District Judge John C. Moffett agreed.

“The loaded handgun, the ammunition, scale, the cash, marijuana,” Moffett said. “It looks pretty bad at this stage.”

The Motel 6 case, as it turned out, was hampered by a victim who was “not very participatory,” prosecutors later said at an April 29 hearing. Aguilar pleaded guilty to malicious destruction of property for breaking the window and agreed to pay Motel 6 $200 in restitution. He received credit for time spent in jail after the arrest and received no additional incarceration.

“He understands that this is not the path he wants to be on,” his attorney at the time said. “As being the second oldest of his [four] siblings, he wants to set a good example for them. This was a day of bad judgment for him.”

But the gun case remained, which kept Aguilar locked in jail. On May 7, prosecutors dropped two felony charges against him, leaving Aguilar charged with four misdemeanor weapons offenses and in a position that led a different judge to release him from jail on a $5,000 bond. Aguilar returned to court on June 22 and pleaded guilty to possession of a firearm by a person younger than 21. Prosecutors asked for a sentence of 45 days in jail, but because Aguilar was entitled to credit for his 38 days in jail from early April to mid-May, followed by credit for home detention, it meant he wouldn’t go back to jail.

He was placed on three years’ probation, including the requirement he get permission from his supervisor before carrying around any firearms, according to court records.

Seven weeks later, about 9 a.m. on Aug. 10, Montgomery County’s 911 center was called about the shooting along Blueridge Avenue, several blocks northeast of downtown Wheaton. Police and medics arrived to find Mendoza dead on the pavement in front of a single-story home.

In the days that followed, detectives arrested Aguilar and a 17-year-old friend who allegedly was with Aguilar when they confronted Mendoza. According to court records, the 17-year-old called a family member after the shooting and said that he was hiding with “Erick” and the police were probably looking for them. Detectives also allege that in the hours before the fatal shooting, the duo robbed two of Mendoza’s friends of their cellphones, according to court records.

Paul Zmuda, an attorney for the 17-year-old, who has been charged as an adult, confirmed the teen was indicted in the case last week but declined to comment further, saying he is just starting to collect information. Court records show that Aguilar was indicted on eight counts, including first-degree murder in the death of Mendoza and two counts of armed robbery for allegedly taking the cellphones from Mendoza’s friends.

As for cases like Aguilar’s gun arrest, discerning intentions is often a big challenge.

“You have to look at someone’s background when they get arrested with a gun to try to figure out is this a blip or is this someone we need to be concerned about,” said Daniel Webster, director of the Center for Gun Policy and Research at Johns Hopkins University. “To me, all the warning signs were blinking for a more robust response. This doesn’t seem to be an individual you wanted to go back on the street so quickly.”

Webster also stressed that gun possession suspects like Aguilar — once released from jail — should be targeted with “relentless outreach” to keep them employed and to provide “practical training on how to slow their thinking and responses down so that they can weigh their options and consequences of their actions.”

Mark Anderson, a Maryland defense attorney who until recently prosecuted gun cases in Montgomery County, said front-line prosecutors in Aguilar’s gun case on the bus probably faced two broader forces: the general push in Maryland’s criminal justice system to go easier on young defendants, led by state legislators in Annapolis, and the coronavirus pandemic.

The coronavirus has compelled courthouses to curb trials, which Anderson said has diminished leverage from prosecutors in plea discussions as their case backlogs grow daily.

“The undertone of everything is to move the cases along. It affects the plea offers and the negotiation process,” Anderson said. “There’s no doubt to me that Aguilar got the covid-19 discount.”

But he agreed that discerning intent in gun cases can be challenging.

“With some of these kids, it’s almost like an accessory,” Anderson said. “They’re more apt to get the gun taken from them than to use it. It can really be that foolish.”

Christopher Herrmann, a crime analyst and assistant professor at the John Jay College of Criminal Justice in New York, said enforcing gun laws should be viewed in the context of what he said is the continued proliferation of guns nationwide.

“The guns are out there. You can’t control that,” Herrmann said. “The only thing you can control is to deter a person’s willingness to carry a gun.”