The deputy director of the FBI has stepped down, a decision that comes amid several weeks of harsh criticism from Donald Trump, US media has reported.

Andrew McCabe resigned from his position on Monday, the Associated Press reported, quoting two anonymous sources familiar with the decision who were not authorised to speak to the media.

The exact reason behind McCabe's early departure from the agency remains unknown, AP said.

White House Press Secretary Sarah Sanders said the White House does not "have any specific comments" on the reports, and she referred reporters to the FBI "on any specifics".

Sanders added the White House had no hand in McCabe's decision to step down.

McCabe, who assumed his position as deputy director in 2016 and had planned to retire this spring, has come under fire from the US president in recent weeks.

Trump has accused McCabe of exerting influence on the FBI's decision not to file charges against Hillary Clinton over her use of a private email server.

In December, he tweeted that McCabe was "racing the clock to retire with full benefits".

Trump also reportedly summoned McCabe to his office in May, shortly after he had fired FBI Director James Comey, to ask him whom he voted for in the 2016 elections, The Washington Post reported last week.

McCabe was serving as the FBI's acting director at the time.

When asked on January 25 to confirm or deny the report, Sanders said: "The president and Andrew McCabe have had limited and pretty non-substantive conversations. I can't get into the details of what was discussed. I wasn't there. There are widespread reports of his retirement."

FBI Deputy Director Andrew McCabe is, and has been, a dedicated public servant who has served this country well. Bogus attacks on the FBI and DOJ to distract attention from a legitimate criminal inquiry does long term, unnecessary damage to these foundations of our government. — Eric Holder (@EricHolder) January 29, 2018

As news of the surprise resignation broke on Monday, Eric Holder, the US attorney general under Barack Obama, tweeted his support for McCabe.

"FBI Deputy Director Andrew McCabe is, and has been, a dedicated public servant who has served this country well," Holder wrote.