Alexandria Commonwealth's Attorney William L. Cowhig yesterday gave up his job as the city's chief prosecutor pending the outcome of his indictment on bribery and illegal gambling charges.

"Because my recent indictment places a cloud over the entire office of the commonwealth attorney. It is apparent that the only way to remove such a cloud is for me to step aside." Cowhig wrote in a four-paragraph letter to Chief Circuit Court Judge Franklin P. Backus.

Backus immediately appointed John E. Kloch. Cowhig's deputy to replace him.

Cowhig's exit from the elected office he has held since 1974 climaxed several days of turmoil in which he was indicted last Thursday, finger-printed and booked Sunday at the Alexandria police station and had personal bond set at $4,000 for his appearance at future court hearings.

Yesterday, visibly upset, he yelled "Leave me alone!" and "This is my staircase!" at reporters following him around City Hall.

Three other men indicted with Cowhig last week appeared yesterday before Judge Backus to be notified formally of the charges against them and to post bond.

Cowhig, 53, did not appear, but legal sources said this was not unusual since he had been booked at the police station the day before.

Backus yesterday told special bingo prosecutor Edward J. White that he would ask the Virginia Supreme Court to appoint a judge to hear the Cowhig case. All of the Alexandria circuit court judges will excuse themselves from the case. Backus said, because they know Cowhig.

Among those indicted, William H. Fields, administrative assistant to City Councilman Nicholas A. Colasanto, who is Cowhig's step-uncle, was freed on $5,000 personal recognizance bond. No trial date was set.

Fields was indicted on one count of conducting an illegal gambling enterprise from 1977 to 1978 in the name of several Alexandria civic associations.

John Michael Keator was freed on $3,000 personal bond and bond was set at $5,000 for George Leonard Berry. Both men are charged with conducting an illegal gambling operation, and both are represented by attorney James J. Burkhardt.

Keator's trial date was tentatively set for Oct. 2 and Berry's for Sept. 20 by Judge Backus. A trial date will be set for Cowhig after the state Supreme Court appoints a judge, Backus said.

Cowhig has hired Arlington trial attorney Louis Koutoulakos to defend him, Koutoulakas confirmed yesterday. One Virginia attorney praised Koutoulakas as "about the best choice (Cowhig) could make."

Roger Amole, president of the Alexandria Bar Association, and one of the strongest voices calling for Cowhig to step aside after the indictments, yesterday praised Cowhig's action. "I hoped he would do it, I think Bill is thinking of the people at Alexandria and the office. I hope he's acquitted," Amole said.

After the news of Cowhig's decision, his longtime administrative assistant Mary Ann (Sam) Pastorek said she had no plans to leave the commonwealth's attorney's staff. "He'll be back," she said, fighting back tears.

Under Section 19.2-155 of the Virginia Code, the section on which Backus acted, Cowhig apparently will go on sick leave, in effect, and will receive his full $42,500 annual salary. The state Compensation Board will decide later for how long Cowhig can continue to qualify for this form of sick leave.