US President Donald Trump has denied that he tried to block an FBI investigation into former national security adviser Michael Flynn, effectively accusing James Comey, the FBI's former director, of lying under oath to Congress.

Mr Comey delivered scathing remarks about the president yesterday at a congressional hearing and testified that Mr Trump had asked him to drop an FBI probe into former aide Michael Flynn and his alleged ties to Russia.

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

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

Asked by a reporter if he had told Mr Comey to drop the investigation into former national security adviser Flynn, Mr 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," Mr 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, Mr Comey also said Mr 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 I do that?" Mr Trump said at a joint news conference with Romanian President Klaus Iohannis.

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

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

Asked today if he would be willing to go under oath to give his version of his interactions with Mr Comey, Mr Trump replied,"100%".

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 Mr Trump's campaign.

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

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

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

A US president is given a wide array of immunities from criminal prosecutions. The US 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.