Judge Royce C. Lamberth ends five years as the District’s chief federal trial judge  Tuesday. (Charles Dharapak/Associated Press)

The outgoing chief judge of the U.S. District Court in Washington created a small stir at his farewell ceremony Monday by joking about the possibility of a federal case against Mayor Vincent C. Gray.

When Chief Judge Royce C. Lamberth steps down Tuesday on his 70th birthday, he will rejoin the ranks of his fellow judges and retake his place in the court’s rotation that determines assignments for new cases.

Lamberth, who is known for speaking his mind, closed his remarks in the ceremonial courtroom by noting as an aside: “I could draw anything, including the mayor.”

With the audience chuckling in response, Lamberth added, “Oops. I don’t know anything about that.”

Watching from one of the front rows of the courtroom was the District’s U.S. attorney, Ronald C. Machen Jr., who appeared to double over at the suggestion.

Machen’s office has been investigating Gray’s 2010 campaign for more than a year. His office appears to be building a case against D.C. businessman Jeffrey E. Thompson, who is alleged to have funded an off-the-books shadow campaign for Gray and who is the subject of a grand jury investigation, according to court records. Neither Gray nor Thompson has been charged, and Gray has denied any wrongdoing.

When asked if he was doubled over in pain or in laughter by Lamberth’s remarks, Machen suggested with a smile that the exchange was not newsworthy.

Mayoral spokesman Pedro Ribeiro said in an e-mail, “We would agree with [Machen] that it’s not newsworthy.”