A British academic has been released from a Middle East jail despite his former captors insisting he confessed to being an operative from spy agency M16.

Matthew Hedges has been pardoned and released from jail in the United Arab Emirates, ending a six-month nightmare for the doctoral student from Durham University.

He was arrested on May 5 and spent an agonising five months in solitary confinement before he was convicted and sentenced last week to life behind bars.

The 31-year-old’s shock arrest came after he’d spent two weeks in the country interviewing people as part of research for his PhD. The interviews were related to the UAE’s foreign policy, and authorities stopped him leaving at the airport because they believed his research was a front for spying.

His jailing caused a major rift between the UAE and the UK, but he has now been pardoned and released.

The shock turnaround has been welcomed by Mr Hedges’s family and the UK Foreign Secretary Jeremy Hunt who has been lobbying for his release.

But it comes as the UAE insist he was a spy and showed journalists grainy footage that purportedly showed him confessing to espionage.

The clip, which officials did not allow journalists to record, shows Mr Hedges describing himself as a captain in MI6 during what appears to be a court hearing.

Another clip appears to show him speaking to someone in an office and saying: “It helps the research to go in an easy way.”

Then Hedges is seen snapping his fingers and said: “Then it becomes MI6.”

In one part of the footage he admits being an M16 officer who was gathering information on the military, and selected industries and government figures while hiding behind his research cover.

One piece of evidence used in court was a video where Mr Hedges was asked his rank in MI6. He replies “captain” - although no such rank exists in M16.

In another video, he is seen in an interview room with two. In English he said he was an MI6 analyst, but then later appeared to change his story and said he was in fact trying to develop sources in the country.

But it is unclear if the statements were made under duress. A family spokeswoman told CNN Mr Hedges was forced to sign a confession in Arabic, a language Hedges does not read nor speak.

It was not immediately clear why he was given a pardon when the UAE has not backed down from the spying claims.

A government spokesman said: “The case against Mr. Hedges was predicated on evidence secured from Mr. Hedges’ electronic devices; surveillance and intelligence gathering by UAE intelligence and security agencies; and evidence provided by Mr. Hedges himself -- including a corroborated account of asset recruitment and training and the confidential information being targeted.”

His wife Daniela Tejada said on Twitter said he couldn’t wait to get him home and his release had “brought me back to life”.

“The presidential pardon for Matt is the best news we could’ve received.

“Thank you friends, family, media, academics, and the wider public for your undivided support - I’ve been brought back to life.”

Foreign Secretary Hunt thanked the UAE for “resolving the issue”.

“Although we didn’t agree with charges we are grateful to UAE government for resolving issue speedily.

UAE minister of state for foreign affairs Dr 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.

Radha Stirling, CEO of UAE justice specialists Detained in Dubai, said the pardon was simply the “UAE is trying to get themselves off the hook by issuing this pardon; they are asking for clemency, not granting it”.

He should never have been locked away and accused of being a spy, she said.

“The pardon does not undo any of that, and indeed, Matthew’s innocence has not been admitted by the UAE; the wrongs done to him have not been acknowledged. Obviously we welcome Matthew’s release, but this is far from an optimal resolution.

He is expected to return to the UK on Monday night (local time).

andrew.koubaridis@news.com.au