A man charged with shooting a college-bound teenager in the head and gravely injuring her as she drove down a street in Northeast Washington was ordered detained on Saturday as his lawyer said her client denied direct involvement.

Philip Carlos McDaniel, 21, told police he drove a gold Honda Accord to near the shooting scene in Brentwood on Thursday and that two men got out, then returned a short time later. McDaniel said he did not see either with a gun, nor did he hear any gunshots, according to an affidavit filed in court.

But Assistant U.S. Attorney Alicia Long pointed to a text message ­McDaniel sent to one of his friends telling them police had seized the ­Honda, which she said exhibited ­evidence of “consciousness of guilt,” supporting the charges even if he did not fire a gun. Police are still searching for the two other men.

D.C. Superior Court Judge Hiram E. Puig-Lugo said there is “ample evidence for probable cause” and ordered McDaniel, who lives in the ­Carver-Langston neighborhood, detained until a preliminary hearing on Aug. 28. He is charged with assault with intent to kill. McDaniel is also facing gun and drug charges stemming from an arrest at his house last month.

The shooting occurred about 3:30 p.m. in the 1400 block of Saratoga Avenue NE. An affidavit says two gunmen hid in bushes on one side of the street and then emerged and opened fire at a group across the street with a .40-caliber handgun and a ­.45-caliber handgun. Twelve ­bullets were fired in all.

Police said one bullet struck a man in the buttocks as he walked out of an apartment building. Another shattered the front passenger window of a white Nissan Versa sedan, sending shards of glass into a passenger’s eye and striking the 17-year-old driver in the head. The Nissan slammed into a parked car.

The gravely injured teenager was taken to a hospital. Her condition has not changed since Thursday, police said, though one of her close friends, 18-year-old A’Mee Barnes, said on Saturday that doctors have indicated the victim can hear people and is aware of her surroundings.

“We’re hopeful,” said Barnes, who visited her friend Friday night. She posted an upbeat message on Facebook late Friday night. “She’s a fighter and will pull through with us.”

The victim’s relatives have not granted interviews, and The Washington Post did not name the teen because she has not been publicly identified by authorities or family. She graduated this spring from Woodrow Wilson High School in Northwest Washington, where she captained the cheerleading squad and sang in the choir. She was looking forward to starting classes at Florida A&M University at the end of the month. Her mother is a 30-year veteran of D.C. police.

Witnesses at the shooting scene told police they saw a gold-colored Honda with New Jersey license plates driving away moments after the shooting.

Police said they found the vehicle a short time later near McDaniel’s house. McDaniel was there and told police he had given friends a ride and that he was trying to sell the car. Police said he has no driver’s license, the Honda was unregistered and the New Jersey plates had been stolen.

Police initially took McDaniel into custody and said in the affidavit that he initially declined to talk to detectives but later changed his mind. He told them he drove two men close to the shooting scene and waited behind as they left. He said he did not see weapons or hear any shots, saying he was playing music.

McDaniel’s attorney, Sara E. Kopecki, argued that there was lack of probable cause to sustain a charge of assault with intent to kill, and that her client cannot be charged with aiding or abetting because he did not know the objective of the two alleged gunmen.

But police said in the affidavit that when police first found the car, McDaniel texted a friend and said, “They just towed the car Moe.” The prosecutor said that text links McDaniel to the conspiracy.