A District lawyer and supporter of Mayor Vincent C. Gray filed a formal complaint Monday against the city’s top federal prosecutor, accusing him of improperly interfering with next week’s primary election.

In a five-page complaint, lawyer Brian Lederer says U.S. Attorney Ronald C. Machen Jr. violated professional ethics in his handling of the long-running investigation into campaign finance irregularities in Gray’s 2010 campaign.

Lederer’s criticism centers on public statements Machen made after a guilty plea by a former D.C. businessman who admitted financing an off-the-books campaign for Gray — in addition to illegally funneling millions of dollars to a long list of other federal and local candidates.

During the plea hearing — which came three weeks before the election — businessman Jeffrey E. Thompson and prosecutors alleged that the mayor was involved in orchestrating the more-than $660,000 “shadow campaign.” During a news conference afterward, Machen told reporters that others involved in Thompson’s schemes should “come forward and own up,” and he warned that prosecutors were “not going away.”

Lederer, a former D.C. People’s Counsel and Democratic Party activist, says in his complaint that Machen’s comments “went well beyond describing the illegal conduct Mr. Thompson admitted to.”

“Machen’s statements have highly prejudiced Mayor Gray’s candidacy and have already had a meaningful impact on the imminent mayoral election,” wrote Lederer, who has donated $700 to the mayor’s reelection effort. Gray has called the assertions “lies.” He has not been charged.

The letter asks the Office of Bar Counsel, which considers complaints about misconduct by D.C. Bar members, to review Machen’s conduct and impose “appropriate discipline.”

Complaints against the city’s top federal prosecutor are highly unusual, and the letter is an example of Gray’s supporters pushing back on the timing of the investigation.

Machen’s office defended its probe in a statement Monday, saying that the timing was dictated by “evidence, not by the news cycle or the election calendar.”

Thompson’s plea deal was finalized March 7 and made public three days later “rather than concealed from the public until after the election.”

Machen had earlier expressed sensitivity to the political calendar, publicly explaining his frustration with legal “obstacles” that he said were preventing investigators from wrapping up their probe.

Staff writer Mike DeBonis contributed to this report