A 31-year-old Maryland man who was held for two months in a federal prison after his case had been dismissed was released yesterday after the error was discovered by District court officials.

D.C. Superior Court Judge Annice Wagner ordered the release of Alvin L. Harris, who had been held without bond at the Petersburg Federal Correctional Facility in Virginia since his arrest in March on heroin distribution charges.

Charges against Harris were dismissed April 8 by the U.S. attorney's office and a release order was signed, but prison officials in Petersburg were not notified until a few days ago when an inquiry from a Harris relative set in motion the events that led to his release.

"Technically speaking, this guy could have been sitting there forever," said his attorney, Sol Rosen.

Law enforcement officials said yesterday that the error apparently occurred when the U.S. Marshals Service, the agency responsible for transporting prisoners, mistakenly sent the release order to the D.C. Jail on April 8 and failed to send a copy to the Petersburg facility where Harris had been held since March 26. Petersburg officials did not find out until Tuesday that Harris' case had been dismissed, according to court officials.

Rosen also said he "just assumed" Harris had been released and felt it was unnecessary to confirm whether he was still in prison. Rosen said it was only when Harris' mother called him this week to inquire about her son's whereabouts that he discovered, several telephone calls and inquiries later, that Harris was still in prison.

"This is a pro forma kind of thing usually," said Rosen.

On Wednesday, officials at the Marshals Service said the foul-up must have been caused by a clerk in the U.S. District Court who failed to transmit a copy of the release order to their office. D.C. corrections officials, however, confirmed yesterday that they had received a copy of the same release order from the marshals April 8, indicating that the clerk's office had passed on the release order.

U.S. Marshal Herbert Rutherford III said yesterday he could not comment on the incident, but would investigate further.

Five days before his latest arrest, Harris had been arrested and charged in D.C. Superior Court with a separate heroin distribution count on March 14. At that time, he was released without bond. He was not detained in prison until March 19 when he was arrested and charged in U.S. District Court with heroin distribution.

Court officials said that after the March 19 charges were dropped, Harris should have been released and returned to his prior status, the action Wagner took yesterday.Staff writer Nancy Lewis contributed to this report.