U.S. President Donald Trump on Friday denied he tried to interfere with an FBI investigation, effectively accusing James Comey, the FBI's former director, of lying under oath to Congress.

Comey delivered scathing remarks about the president on Thursday at a congressional hearing and testified that Trump had asked him to drop a Federal Bureau of Investigation probe into former aide Michael Flynn and his alleged ties to Russia.

Trump said Comey's testimony also vindicated him from allegations that he colluded with Russian meddling in the 2016 U.S. presidential election.

"James Comey confirmed a lot of what I said. And some of the things that he said just weren't true," Trump said at a news conference in the White House Rose Garden.

Asked by a reporter if he had told Comey to drop the investigation into former national security adviser Flynn, Trump said, "I didn't say that."

The reporter then asked, "So he lied about that?"

"Well, I didn't say that. I mean, I will tell you, I didn't say that," Trump replied. "And there would be nothing wrong if I did say it according to everybody that I've read today, but I did not say that," he said.

In his testimony, Comey also said Trump asked him in January to pledge loyalty to the president, an unusual request that would put in doubt the independence of the FBI.

"I hardly know the man. I'm not going to say I want you to pledge allegiance. Who would do that?" Trump said.

Comey's testimony was the most eagerly anticipated U.S. congressional hearing in years. The issue of the Trump election campaign's relationship with Russia has dogged Trump's first months in office and distracted from his policy goals such as overhauling the U.S. healthcare system and making tax cuts.

Comey, who was fired by Trump in May, did not make any major disclosures about any links between Trump or his associates and alleged Russian meddling.

Asked on Friday if he would be willing to go under oath to give his version of his interactions with Comey, Trump replied, "100 percent."

He said he would be happy to speak to special counsel Robert Mueller, who is investigating allegations that Russia interfered with the election and colluded with Trump's campaign.

"I would be glad to tell him exactly what I just told you," Trump told a reporter.

Several congressional committees, as well as the FBI and Mueller, are looking into the Russia allegations. On Friday, the leaders of the House of Representatives intelligence committee's investigation said they had asked Comey for his notes and memos about his discussions with Trump, and asked the White House to produce any recordings or memos of conversations between Trump and Comey.

Trump declined to answer questions from reporters about whether recordings existed. "I'll tell you about that maybe sometime in the very near future," he said.

Trump’s offer to testify under oath would pit his word against Comey’s before federal investigators.

If either Trump’s testimony or memos written by Comey about his conversations with the president turn out to be untrue, either man could be charged with lying to federal investigators.

A U.S. president is given a wide array of immunities from criminal prosecutions. The U.S. Constitution does not directly address whether the president can be criminally prosecuted, and the area is the subject of legal debate. A president can be charged after leaving office.

Trump wrote earlier on Friday on Twitter that the former FBI head had vindicated him by telling the Senate Intelligence Committee that the president had not been personally under investigation in the Russia probe.

With a single tweet, Trump also castigated Comey as "a leaker" for giving an account of his conversation with the president to a law professor who shared it with a news outlet.

"Despite so many false statements and lies, total and complete vindication ... and WOW, Comey is a leaker!" Trump tweeted.