WASHINGTON — President Trump’s lawyer Rudolph W. Giuliani has contradicted Mr. Trump’s rationale for firing James B. Comey as the F.B.I. director, saying he was dismissed because he would not say publicly what he had told the president privately: that Mr. Trump was not under scrutiny in the Russia investigation at the time.

“He fired Comey because Comey would not, among other things, say that he wasn’t a target of the investigation,” Mr. Giuliani said in an interview late Wednesday with Sean Hannity of Fox News. “He’s entitled to that.”

Mr. Giuliani’s assertion contradicted the myriad explanations that the president and his aides have given for the firing, and was the first public acknowledgment by a Trump adviser for what Mr. Comey has maintained: that he was fired for his handling of the Russia investigation.

At the time of Mr. Comey’s dismissal last May, both Mr. Trump and his aides cited his handling of the investigation into Hillary Clinton’s use of a private email server and his decision to say publicly during the 2016 presidential campaign that Mrs. Clinton, the Democratic candidate, would not be charged with a crime.