Qatar has begun an inquiry into a cyberattack by hackers who posted fake remarks on its official media platforms by its ruler purportedly criticising US foreign policy.

The incident comes just days after President Donald Trump met Gulf Arab leaders in Riyadh, Saudi Arabia.

"The Qatar News Agency (QNA) website has been hacked by an unknown entity. A false statement attributed to His Highness has been published," a government statement early on Wednesday said.

Qatar will track down and prosecute the perpetrators, the statement said.

In addition, the hacked Twitter account contained a false story in Arabic apparently from the country's foreign minister, Mohammed bin Abdulrahman Al Thani, about Qatar withdrawing its ambassadors from several nearby countries.

Government Communications Office Statement Regarding Hacking of #Qatar News Agency: pic.twitter.com/gRH56n9vEm — سفارة دولة قطر-لندن (@QatarEmbassyUK) May 24, 2017

Despite robust denials by Qatar, throughout Wednesday official media in Saudi Arabia and the UAE ran the remarks falsely attributed to Emir Sheikh Tamim bin Hamad Al Thani on QNA platforms.

An official in the Qatari foreign ministry expressed "surprise at the position of some media and satellite channels".

Authorities in Saudi Arabia and the UAE blocked the main website of Al Jazeera late on Tuesday.

Regulators and government officials in the UAE did not respond to media requests for comment.

Al Jazeera has said it is "studying the reports our channels and digital platforms have been blocked in certain countries in the region".

The Doha-based media network has maintained that it is an independent news service giving a voice to everyone in the region.

The fake report said Sheikh Tamim, in a speech at a military graduation ceremony, was critical of renewed tensions with Iran, expressed the need for contextualising Hezbollah and Hamas as resistance movements, and suggested that Trump might not last long in power.

Reuters news agency quoted a Qatari government spokesman as saying that while Sheikh Tamim had attended a graduation ceremony for Qataris doing national service, he "however did not make any speech or give any statements".

Investigation launched

Sheikh Saif bin Ahmed Al Thani, director of Qatar government's communications office, issued a statement saying authorities had launched an investigation.

"The statement published has no basis whatsoever and the competent authorities in the state of Qatar will hold all those [who] committed [this] accountable," he said.

The government said the state TV footage posted online were "fake videos".

No group has claimed responsibility for the incident.

Qatar, however, has been targeted by hackers before. In May 2016, hackers leaked sensitive information involving thousands of bank customers.

Recently, Qatar issued a statement condemning "an orchestrated barrage of opinion pieces by anti-Qatar organizations" criticising it.