The Bronx district attorney on Wednesday asked a judge to dismiss gun and assault charges against a teenager in a case that had become a rallying point for critics of the criminal justice system, saying a crucial witness had disappeared. The teenager, Pedro Hernandez, had refused a plea deal, then sued the city, alleging that police detectives in the 42nd Precinct framed him.

The district attorney, Darcel D. Clark, said in a statement that her office was investigating the actions of the police and prosecutors who obtained the indictment against Mr. Hernandez; she promised to “go wherever the evidence leads.”

Mr. Hernandez, 17, smiled as Justice Steven Barrett, who had held him in jail for a year on $250,000 bail, agreed to throw out the gun possession and assault charges against him, while a crowd of news photographers in the jury box recorded the scene. Mr. Hernandez still faces a robbery charge in an unrelated case.

“My thought was just to have faith,” he said outside the Bronx County Hall of Justice. “I knew it was coming all along. It was just a matter of time.”