Two American guards are shackling a shaven-headed prisoner in a Camp X-ray orange boiler suit, putting him in goggles and ear muffs. He wails as if in real pain. But this is not Cuba, it is Iran, seen more often in the West as the sort of radical theocracy evoked by its President's comment last week that Israel should be "wiped off the map". And next to the cages where prisoners loll against wire mesh, the British director Michael Winterbottom is squinting through a camera lens, a small crew hovering near by.

While the world was up in arms over Mahmoud Ahmadinejad's anti-Semitic outburst and the mass demonstrations and flag burnings were splashed across Western media, Winterbottom, one of Britain's top cinematic talents, was just a few miles away in a very different Iran. Off set, actors, extras and the production team sip tea and smoke cigarettes while a fat Iranian policeman in a green shirt sits near by, a benign smile on his moustachioed face, adding to the surreal air of the scene. A handful of Baluchis and Afghans, also in orange, squat on their heels looking on with bemusement as a motley collection of foreigners and fair-looking Iranians try on American military uniforms, swapping caps and squabbling over who will carry the guns.

Inside the Camp X-ray compound, guards pace up and down with vicious-looking dogs. Two more guard the entrance, opening it as the shackled man is dragged towards the cages, his fettered feet unable to keep pace with the long strides of the guards. "And we're rolling," shouts the assistant director, demanding quiet. The film crew wear incongruously trendy clothes, bringing a peculiar scent of London media life to the earthier flavours of Cuba and Iran.

On the surface Iran might seem a strange place to shoot Winterbottom's latest film, a retelling of the harrowing tale of the Tipton Three, Britons who ended up at America's notorious Guantanamo Bay. Furthermore, gaining permission to turn a disused military base into a film set seems even more unlikely.

"We were mainly filming things that happened in Pakistan and Afghanistan and although we did shoot some stuff there, it was too complicated and maybe unsafe," Winterbottom says.

"We needed the right landscape and ethnic mix to recreate Afghanistan and you get that in southern Iran."

He has filmed in Iran before, when making In This World (2002), which followed the story of two Afghan refugees as they travelled across Asia in the hands of people smugglers. So what are the problems you face making a film in a country where public morality, religion and politics often come to the surface of daily life? "No problems, only challenges," he is quick to insist (perhaps he wants to work here again). So what are the challenges? He remains coy. "Whenever you work abroad - not just Iran and countries like it - there are issues like how different cultures will work together. Plus Iran is difficult with visas and so on. But that would be a problem for Iranians coming to the UK too." Iran is internationally recognised for the high quality of art films it puts out. The director Mohen Makhmalbef is often referred to as a cinematic genius - and the domestic industry is equally prolific, with less high-brow but more entertaining films that frequently push the boundaries of what is legal and acceptable. But most foreign companies that try working in the Islamic republic say it can be a frustrating experience.

Off set, I hear whispers about Iranian officials reacting inflexibly to possible script changes - although as the film is never set in Iran, they have not tried to censor anything as they have had no reason to do so. Other issues revolve around the difficulty of allowing women to have hair uncovered on set and misunderstandings about what sort of extras would be needed.

But somehow progress is being made in this make-believe Cuba. To the north, jagged, barren mountains drop down to what feels like desert. Winterbottom says they will be blurry enough on screen to pass for the vegetation-covered hills of Cuba. A little way to the south lies a deceptively tropical plantation of trees. Welcome to the new Guantanamo a few kilometres west of Tehran. The Afghanistan scenes were largely filmed near Zahedan, the capital of the lawless Baluchistan Province of Iran's south-west.

In Baluchistan, schedules were stricter because of violence. At night, drug smugglers and army patrols rule the desert, doing for real what the film crew has staged at day. On the Tehran set, thermal underwear must be provided because the warm daytime temperature drops suddenly when the sun goes down. Autumn in northern Iran is a season of frost. The actors playing prisoners did not want their heads shaved because in the Middle East and parts of central Asia it is a mark of shame. Many of them were chosen for their ethnic make up and linguistic skill. Tehran is a sort of central Asian melting pot, where Arabs, Azeris, Afghans and Armenians rub shoulders with Kurds and Baluchis. People here can pass as anything from Chinese to Pakistani or Chechen to Arab. And many of them speak the languages of those interred in Cuba.

Winterbottom has a reputation for cutting-edge films. Other major credits include 24-Hour Party People (2002), the sexually explicit 9 Songs (2004), Welcome to Sarajevo (1997) and Jude, his first major film (1996). He is not afraid to tackle stories that address the most controversial issues without being doctrinaire.

"What was nice about this was they were such ordinary kids," said Winterbottom, whose co-director Mat Whitecross spent months interviewing them. "And then they were put in this extraordinary situation, spending three years in Guantanamo."

Winterbottom likes to use non-actors in his films, which together with the hand-held camerawork and penchant for filming out of studio, helps give his films the gritty, intimate feel achieved with In This World. Of the three young men playing the leads only one, Riz Ahmed, was already an actor - freshly out of drama school. The other two, Farhad Harun, who plays Ruhel, and Arfan Usman, who plays Asif, were chosen because they fittedwell with the background of the real characters. "In a sense we were cast because we're close to the people we're playing - maybe me less than the others," said Ahmed, who comes from Wembley but cannot shed the Birmingham accent he has spoken with for the past few months.

"The fact it was almost a recreation made it weird but it gives you direction. Once you realise it's OK to put something of yourself into the role it's fine."

Winterbottom's organic directing style helps this process as well. "Michael gives you really free rein," said Ahmed. "He's very open to suggestions - even if it involves doing a scene from scratch. So in Afghanistan, a random kid turned up with a parrot and we put him in."

Feeding time in the cages. A double row of cells - made simply of wire and a few feet square - sit under a small watchtower. Each contains a Koran, a blanket and two buckets for washing and waste. The actors sitting inside have already acquired the calm watchfulness of prisoners.

The extras playing guards have been recruited from the film crew and pliable Westerners living in Tehran. This eclectic group takes in African-American basketball players who ply their trade in the Iranian basketball league, journalists like me, and a Bosnian film student, studying in Tehran to avoid national service at home. Loafing against the side of a gate in full uniform, assault rifle dangling nonchalantly from his shoulder, he says it is this sort of hanging about that really explains why he wanted to avoid the military.

"Back of the cells, hands on heads," Winterbottom tells the guards to shout. Prisoners must "look like this is completely routine. It's normal and boring and you're very hungry, even if you've just had lunch off set". There are two guards on each side, one to unlock the door, the other to thrust in a plate of food. One prisoner has dozed off. My moment of fame - I have been roped in to play an American guard - comes and I roughly shake him awake. He looks daggers at me before wolfing his lunch, sealed in a US military standard-issue packet.

There is a post-production party downstairs in the hotel. Coke (cans not lines) and cake to say goodbye and thank you. Extras, actors and people who just passed by in the night stop to pay their regards. There are performances: magic tricks, blues singing and a rap, with the hotel staff, eyes goggling, watching from the wings. And suddenly it is very normal. This could be London or any other international city and yet only a few kilometres away, the revolutionary faithful had been thronging in the streets. The conversation turns to Islam and cultural conflict, stretching across continents, philosophies and religions. It is a thoroughly fitting way to end a most peculiar shoot.

Prisoners' story

Ruhel Ahmed, Asif Iqbal and Shafiq Rasul were captured by Northern Alliance forces in northern Afghanistan in November 2001 and handed to the US military. The three young men, all from the Tipton area of Birmingham, were finally released from Guantanamo Bay without charge in March 2004. Michael Winterbottom has set out to recreate their extraordinary story.

The three, all from Pakistani families, had travelled to Karachi with another friend in the summer of 2001 for Asif's wedding. According to their own accounts, they then travelled into Afghanistan as backpackers and were caught up in the US occupation.

Their account is harrowing. It details the freezing cold and illness that characterised their journey in Northern Alliance lorries, in which they said only 20 of 200 prisoners survived. They say they were then beaten severely by US soldiers who took charge of them inside Afghanistan and subjected them to humiliating treatment.

After their removal to Guantanamo, the trio say they endured torture, including exposure to intense heat and cold in open cages, where scorpions, snakes and rats roamed freely. Inmates were bitten. The guards were also brutal, frequently beating inmates, according to a report prepared on the men's behalf by lawyers from the US-based Centre for Constitutional Rights.

They said the regime became particularly severe in late 2002 when Major General Geoffrey Miller took charge of the camp before his move to Iraq. The report said he gave military interrogators freer rein, allowing the use of more sleep deprivation, loud noises, short-shackling and other techniques classed as torture. The young men described how other inmates lost their minds or were beaten until they suffered brain damage.

But how does a director tell such an emotionally charged and politically controversial story fairly? Winterbottom says he is simply examining the failure of a wider policy rather than specific charges. "You have this situation where America is being criticised all over the world for these camps and now we find that most of the real suspects were anyway being farmed out elsewhere on extraordinary rendition programmes," he said. "So it's this huge issue with very ordinary people being treated like they're the most dangerous criminals on earth."

Tourists are limp, leaderless and distinctly UnAustralian

Andrew Grice: Inside Westminster

Blairites be warned, this could be the moment Labour turns into Syriza

The mystery of Britain's worst naval disaster is finally solved - 271 years later

Exclusive: David Keys reveals the research that finally explains why HMS Victory went down with the loss of 1,100 lives

'I saw people so injured you couldn't tell if they were dead or alive'

Nagasaki survivors on why Japan must not abandon its post-war pacifism

The voter Obama tried hardest to keep onside

Outgoing The Daily Show host, Jon Stewart, became the voice of Democrats who felt the President had failed to deliver on his ‘Yes We Can’ slogan. Tim Walker charts the ups and downs of their 10-year relationship on screen