China has denied an accusation by President Donald Trump that it hacked the emails of Hillary Clinton, his Democratic opponent in the 2016 election.

"We are firmly opposed to all forms of cyberattacks and espionage," foreign ministry spokeswoman Hua Chunying said at a regular briefing Wednesday. She said China is a staunch defender of cybersecurity.

Mr. Trump tweeted shortly after midnight that China had hacked Clinton's emails, without offering any evidence or further information, and suggested that the FBI and Department of Justice should investigate.

Hillary Clinton’s Emails, many of which are Classified Information, got hacked by China. Next move better be by the FBI & DOJ or, after all of their other missteps (Comey, McCabe, Strzok, Page, Ohr, FISA, Dirty Dossier etc.), their credibility will be forever gone! — Donald J. Trump (@realDonaldTrump) August 29, 2018

"Hillary Clinton's Emails, many of which are Classified Information, got hacked by China. Next move better be by the FBI & DOJ," he tweeted.

Get Breaking News Delivered to Your Inbox

His tweet was the latest public attack against his own intelligence agencies, claiming that with previous "missteps" the agencies' "credibility will be forever gone."

U.S. intelligence agencies have accused Russia of involvement in the hacking of Democratic emails during the 2016 election campaign. The Justice Department has indicted 12 Russian intelligence officers accused of hacking into Clinton's presidential campaign and the Democratic Party.

Special counsel Robert Mueller is investigating Russia's role in the election and whether there was any collusion between it and Mr. Trump's campaign.