A cabdriver accused of shooting and critically wounding an Alexandria police officer in February has been declared incompetent to stand trial and will be sent to a state mental hospital so doctors can try to rehabilitate him psychologically, authorities said.

Prosecutors and defense attorneys agreed that Kashif Bashir could not assist in his own defense or understand the proceedings in his case, and they asked an Alexandria Circuit Court judge Thursday to declare him unfit for trial, authorities said.

Judge James C. Clark entered an order declaring Bashir incompetent, meaning proceedings in his case will be put on hold unless the 27-year-old can be rehabilitated, said Alexandria Assistant Commonwealth’s Attorney Bryan Porter.

Emily Beckman, Bashir’s attorney, had written in a court filing that her client thought people involved in the case had shape-shifted and communicated with him telepathically. A doctor was then ordered to evaluate him and complete a report — which remains sealed — about his competency, Porter said.

Prosecutors have accused Bashir of shooting and wounding Officer Peter Laboy in an apparently random daylight attack in Old Town Alexandria on Feb. 27. First-graders at a nearby school were outside playing when the shooting occurred.

According to testimony at a previous hearing, the Alexandria officer, known for his friendliness and dedication, was shot without warning as he tried to stop a “suspicious” cabbie who had just driven away from another officer.

Bashir was arrested after a high-speed chase and is charged with attempted capital murder of a police officer. Laboy was critically wounded but has substantially recovered. He recently left for a vacation to see family in Florida and the Dominican Republic, according to a blog that his wife maintains.

In filings before Thursday’s hearing, Beckman wrote that Bashir asked whether his lawyers were the police detectives who interviewed him “in another form,” and “expressed the belief that one of his lawyers might have visited him inside the housing unit of the jail in the form of a much older jail worker.”

Beckman wrote that Bashir also thought that a prosecutor communicated with him telepathically in an earlier hearing and was convinced that a prosecutor and judge had continued to do so after that.

Porter said Bashir will temporarily be sent back to jail but then will be transported to a state hospital so he can be treated by psychologists and psychiatrists. Another hearing is scheduled Jan. 9, although Bashir could appear in court sooner if hospital officials think his condition improves to the point where he can understand court proceedings, Porter said.