UAE Ambassador to the U.K. Sulaiman Hamid Almazroui delivers a statement to the media about Matthew Hedges on November 23, 2018.Frank Augstein / AP

A British graduate student who was detained in the United Arab Emirates for alleged espionage spoke publicly about his ordeal for the first time this week. Matthew Hedges was arrested in May, detained, and sentenced to life in prison for “spying for a foreign country” and for “jeopardizing the military, economic and political security of the UAE.” He was released on November 26 after he was granted a pardon. In his statements to the media, Hedges said he confessed under duress after interrogators threatened to torture him at an overseas military base.

I lived and worked in the UAE for seven years, and I interacted with Hedges several times in 2014. Understanding the context for Hedges’s ordeal could help others avoid his fate. He clearly was not a spy, as the United Kingdom’s government and his academic colleagues insisted when his case became public. And I have no doubt that the cause of his seven-month detention was his openness about his main research topic: the inner workings of the UAE’s security apparatus.

The UAE security force, which has taken on an increasingly prominent role since the Arab uprisings in 2011, is a topic Emirati citizens avoid. It has played a pivotal role in purges against Islamists and political activists over the years, and is responsible for thousands of expulsions and deportations of academics and professionals from the UAE.

On a few occasions during my stay in the UAE, Emiratis spoke to me about the heavy hand of the security apparatus; some were unable to get government jobs because they had a relative with Islamist links, for instance. But they always discussed their troubles in highly general or vague terms—sometimes they used gestures instead of words— and only in safe settings to trusted friends. Emiratis are afraid of the security force, and rightly believe its sovereign decisions cannot be appealed, not even by the country’s rulers.

It is hardly surprising that a foreign researcher asking questions about the country’s security structure would raise eyebrows. Hedges told The Times of London that he was shocked when one of his Emirati friends testified against him—but he shouldn’t have been.

Journalists and researchers in the UAE often have tense encounters with state-security personnel. Interrogations are incessant and engineered to produce a confession, which, of course—especially after several hours—seems like a good alternative to torture or deportation.

Hedges told CNN that the initial questioning involved a series of accusations: “They started off as asking me if I was a member of the [British] Foreign Office. Then it went to: Are you a member of MI6? And then they [continued] going down this line. This is when they asked me later what rank I was, and they said, ‘Are you a second lieutenant, first lieutenant, captain, major?’ And then in a moment of panic, I was like, ‘Yeah, yeah, sure, I’m a captain,’ just to try and appease them.”

Hedges’s interrogation experience sounded familiar to me. In early 2010, I was working as a reporter in the UAE for The National, an English-language daily. After a volcanic eruption in Iceland coated Europe in ash, I was assigned to cover the ensuing flight disruptions, the most dramatic since 9/11. Naturally enough, I went to Abu Dhabi International Airport to speak to the arriving passengers. A man with plain clothes approached me and asked me why I was speaking to travelers. Then another person stepped in, and they asked me to come with them. More security men came. One asked me not to “escalate” the situation. I kept saying I was a journalist, merely doing my job. When I suggested that treating journalists roughly would hurt the UAE’s image, one guard scolded me: “Don’t speak about the UAE’s image.” I backed down and stuck to answering questions. Eventually, after checking my credentials, they let me go.

Hedges wasn’t so lucky, in part because a local witness had claimed that he was a spy. With that (false) tip in hand, they must have been determined to obtain a confession. Law enforcement in the UAE always err on the side of suspicion. A former British colleague, for instance, was arrested in 2014 after a security guard reported that she’d taken a picture of the Syrian embassy. In the UAE, it’s illegal to photograph an embassy, even if it happens to just be in a picture taken from a distance. Although the police ultimately found no pictures of the embassy in her possession, they still took her into custody. She was questioned for nearly a week.

Academics and journalists walk into a minefield when they conduct work in Arab countries. To avoid trouble, they first have to realize that many of these countries are less tolerant than they may appear. The UAE welcomes foreigners and foreign investment—but that doesn’t mean it’s open. There are unwritten, unspoken redlines that journalists cross at their own risk; the security apparatus and stateless residents are both redlined topics, for example. Explicit criticism of Saudi Arabia, Egypt, or even President Donald Trump will also lead to trouble as censorship becomes a form of courtesy to allies.

Researchers who are determined to study the Arab world should familiarize themselves with the environment and culture. They can go through official channels to obtain an official version of events—that has its uses. If they want the “real story,” they have to take time to build relationships before asking any sensitive questions whatsoever. (Hedges asked questions openly, which must have scared his subjects.) To achieve a breakthrough, researchers must commit to years of immersion, and expect to scrape together fragmented conversations or observations. And always, they must keep in mind the risks. Hedges wasn’t the first academic to stand accused of spying, and he won’t be the last.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.