Foreign Secretary Jeremy Hunt said the news, announced at a press conference in the UAE on Monday, was “fantastic”.
The 31-year-old, originally from Exeter, was arrested at Dubai Airport as he tried to leave the country on May 5.
Speaking at the press conference, a UAE official said the country stands by the charges against Mr Hedges, but that the academic was being pardoned, alongside 784 other prisoners, as part of the UAE’s 47th National Day.
The spokesman said Mr Hedges was “100% a full-time secret service operative” who was in the country “to steal the UAE’s sensitive security national secrets for his paymasters”.
He said the Briton’s pardon was in response to a letter from his family appealing for clemency and due to the historical close ties between the UK and UAE.
“His Highness has decided to include Mr Matthew Hedges among the 785 prisoners released,” he said.
“Mr Hedges will be permitted to leave the country once all the formalities are complete.”
UAE minister of state for foreign affairs Anwar Gargash said the pardon would allow the UAE and UK to “return our focus to the underlying fundamental strength of the UAE-UK bilateral relationship”, the WAM Emirates news agency reported.
Dr Gargash said: “His Highness the President’s gracious clemency in the customary National Day pardons allows us to return our focus to the underlying fundamental strength of the UAE-UK bilateral relationship and its importance to the international community.
“It was always a UAE hope that this matter would be resolved through the common channels of our longstanding partnership. This was a straightforward matter that became unnecessarily complex despite the UAE’s best efforts.”
Mr Hunt said news of Mr Hedges’ pardon was “bittersweet” given that Briton Nazanin Zaghari-Ratcliffe remains detained in Iran, also accused of spying.
He tweeted: “Fantastic news about Matthew Hedges. Although we didn’t agree with charges we are grateful to UAE govt for resolving issue speedily. But also a bittersweet moment as we remember Nazanin & other innocent ppl detained in Iran. Justice won’t be truly done until they too are safely home.”