Washington: John Bolton, who served as Donald Trump's national security adviser before becoming one of the US president's most prominent critics, pleaded guilty on Friday to one count of retaining classified documents.

The 77-year-old former diplomat entered the plea in a federal district court in Maryland as part of a plea agreement under which prosecutors will recommend a prison sentence of no more than five years.

When US District Judge Theodore Chuang asked whether he was guilty, Bolton replied: "I am, your honour, and I'm sorry for it."

In addition to the prison recommendation, Bolton has agreed to pay a fine of $2.25 million.

Charges stem from handling of classified material

Bolton was indicted in October on 18 counts of transmitting and retaining top secret national defence information.

Prosecutors alleged that he shared classified files by email with two unauthorised individuals. Their identities have not been officially disclosed, although they are believed to be his wife and daughter.

According to the allegations, the classified material was later used in The Room Where It Happened, Bolton's book that sharply criticised the Trump administration.

Bolton served as national security adviser during Trump's first term and has since become a frequent television commentator and newspaper contributor, repeatedly criticising the president. He has previously described Trump as "unfit to be president".

Trump has also publicly criticised his former aide and withdrew Bolton's security detail shortly after returning to the White House in January last year.

The Trump administration's Justice Department has also pursued criminal cases against other prominent critics of the president, including New York Attorney General Letitia James and former FBI director James Comey.

Bolton is scheduled to be sentenced on October 28.