Prosecutors dropped the charges Friday against two teenagers who had been accused in the stabbing death of a 74-year-old man in Riverdale last year, authorities said.

Marcus C. Ferguson, 17, and Kenneth B. Gails, 19, had been charged with murder and other counts in the Aug. 2 stabbing of 74-year-old Glenn Ralph Adkisson. Nancy Lineman, a spokeswoman for State’s Attorney Angela Alsobrooks, said prosecutors had “no other choice” but to drop the case because of a lack of evidence.

“This was an immensely difficult case for us to have to drop, but we just didn’t have the evidence to move the case forward through the criminal justice process,” she said. She declined to comment further.

Police said at the time the charges were filed that Ferguson and Gails were known in the neighborhood where the slaying took place —  the Parkview Gardens apartment complex on 64th Avenue — and they provided statements implicating themselves in the robbery. Adkisson, a retired truck driver who had spent about 20 years in the Air Force, lived in the neighborhood and was out taking his family’s Pomeranian for a walk when he was apparently attacked, police have said.

That much is still true. But Thomas C. Mooney, Gails’s defense attorney, said his client had an alibi and only told detectives what he thought they wanted to hear.

“What he ultimately admitted to was, in essence, being there,” Mooney said. “He was put in a position where he felt he had to agree to their story, in part in order to leave criminal investigations and go to a commissioner.”

Mooney said Gails had just begun work at a basement renovation company, and his boss was willing to testify that he had been working on the day of the murder. Cell phone records corroborated Gails’s account that he moved between a job site in D.C. and his boss’s house in Silver Spring on the day of the slaying and could not have been at the scene, Mooney said.

“He was absolutely not there,” Mooney said. “The problem is the procedure used to elicit those statements, depending on what version you believe, is very questionable.”

Mooney said detectives rejected Gails’s initial claim that he was not at the murder scene, and Gails was told Ferguson had implicated him in the slaying.

Mooney said both Gails and Ferguson will be immediately released. Both men have been incarcerated since arrest.

Michael Beach, Ferguson’s defense attorney, said he is “pleased and grateful that the assistant state’s attorney did the right thing in dismissing the case against Mr. Ferguson, who always was innocent of these charges." He declined to comment further.

Julie Parker, a Prince George’s County police spokeswoman, declined to comment.