In a surprise move, a Richmond lawyer who had emerged as the leading contender for the post of U.S. attorney in Alexandria withdrew from consideration earlier this week without explanation.

Matthew N. Ott Jr., a criminal law specialist and former Henrico County assistant prosecutor, said yesterday, "I just think it's in my best interest to stay where I am for right now." He refused to elaborate.

Ott, 34, is an outsider to Virginia Democratic party circles. Sources said yesterday his selection ran into opposition from such party leaders as Lt. Gov. Charles Robb and state party chairman Richard Davis.

Robb, Davis and other Democratic leaders told contacts in the Carter administration that they would prefer a party regular in the post, sources said. Neither Robb, who is on a trip on the Far East, nor Davis was available for comment yesterday. The White House had no comment.

"all of us were very upset when we heard he [Ott] was the main candidate, because none of us had ever heard of him," said one party official from Northern Virginia.

But the official and other Democratic sources said they were surpised to hear of Ott's withdrawal and could not say whether it was linked to political considerations.

Ott's name first surface in May when a Justice Department spokesman said the lawyer headed a list of fewer than five candidates for the post. He was said to be the top choice of Attorney General Griffin Bell and other senior Justice officials because of his experience as a criminal prosecutor. He was also said to have strong support from U.S. District court Judge Robert Merhige, for whom Ott once Served as a law clerk.

William Tyson, acting director for the Justice Department's excutive office for U.S. attorneys, said yesterday he had no explation for the withdrawal, which was contained in a brief latter from Ott that the department received Wednesday.

Tyson said Ott was the only candidate who had gotten a full review for the post, which was vacated June 1 by William B. Cummings, a Republican. Justin W. William has served as interium U.S. attorney since then.

One Virginia Democrat said party leaders have submitted a list of candidates they would like to see considered for the post. The list is said to include former Virginia Attorney General Anthony Troy, Arlington attorney John T. Schell, who was an unsuccessful candidate for attorney general two years ago, and Arlington Commonwealth's Attorney William Burroughs.