Drive north of Kabul for an hour, turn left into a grey desert and head east for fifteen minutes, the sand shawling up the side of the windows until an armed man in the uniform of the Iranian police stops you before a forbidding compound of watchtowers, mud walls and razor wire. For a brief moment, that willing suspension of disbelief - I can see the inmates sitting on the sand beyond the iron gate – I forget that this is an Afghan movie set, and that Daoud Wahab, the producer of 'The White Rock' is sitting in front of me. "Looks real, huh?" he asks over his shoulder. It does.

For incredibly, as Afghanistan sinks back into the anarchy which became its natural state these past 29 years, Afghan film-makers are producing movies of international quality, turning out pictures which prove – even amid war – that a country's tragedy can be imaginatively recreated for its people. Safaid Sang – Dari (Persian) for White Rock – was an Afghan refugee detention camp inside Iran whose Iranian guards helped to massacre more than 630 of their prisoners in 1998 after inmates protested at their treatment. The atrocity – largely unknown in the West – ended after two Iranian helicopters strafed the Afghans with machine guns. Quite a story. Quite a movie.

"I'm really hoping for something big for this," Wahab says as he eases himself into the producer's folding canvas chair inside the prison gate. "We built all the mud walls, bought the razor wire, constructed the concrete lavatories – we even made fake shit to put all over the floor – and I found a real Iranian flag in the 'souk' in Kabul." It snaps above us now in the desert wind, the silken split-onion symbol of the Islamic Republic between red and green, the banner fringed with gold. The guards even speak with the right accent because some are half-Iranian. At least one of the actors was himself a prisoner in the real camp.

Download the new Independent Premium app Sharing the full story, not just the headlines

The Afghan actors squat beside an inner fence of wire, pleading with family visitors for help while the 'guards', immaculately dressed in near-perfect Iranian uniforms – Wahab and director Zubair Farghand searched the internet for photographs which showed cap badges and insignia of rank – shout abuse at their charges. One young man with an American rifle – the real Iranian police do indeed have US weapons – walks up to a 'prisoner' and kicks him brutally in the back, pulling out a cosh and bashing him on the legs.

"I think he enjoys beating these people – he's grown into the part," Wahab says sharply. He paid £30 for each of the 64 refugee tents to be sewn and patched together in the bazaar. They are a distressing backdrop to the White Rock camp where the dust and wind bleach out the colour of the landscape, even the great mountains that shoulder their way across the landscape, the foothills of the Panshir Valley. The movie, of course, is called 'The White Rock'.

But unkind thoughts move through my mind. When the Third Reich was collapsing, didn't Goebbels produce an epic movie about Frederick the Great to boost the morale of German troops? And – while I made sure that Daoud Wahab didn't take offence at the Hitler parallel – wasn't there a certain irony that his film was being shot scarcely three miles from the vast American base where Afghans prisoners are held in their hundreds, even as we sit in this desert today, and where US personnel have sadistically tortured – perhaps still do torture – their inmates. Why not make a film about this far more contemporary violence?

"If we get a chance in the future, I'm sure we will," Wahab says – I am not entirely convinced by this – "and there will come a time. But we don't need problems from the Americans now. Yes, there is a prison in Baghram, and there is mistreatment there, but now we are completing this earlier piece of history. We've told the Americans we are making this film here, just in case they wonder why there's another 'prison' in the area." On cue, a US chopper comes thundering over the desert and a C-130 transport sails high above us in the yellow, sand-coloured sun.

"A part of Iranian society had a madness towards the Afghans," Wahab says. "There were social, economic problems at the time. There was a lot of prejudice against Afghans because the refugees provided cheap labour in Iran and contractors therefore preferred Afghan labour rather than Iranians. When the refugees started complaining about their bad treatment, something snapped. But can you blame the Afghans for protesting? Iran had taken tens of thousands of refugees fleeing first the Russians. then the 'mujahedin' and then the Taliban -- but these prisoners even had to rent boots to walk in the faeces encrusted on the floor of the camp latrines. When they found prisoners gambling at night, each of the Afghans was given a hundred lashes by the Iranian police."

A camera moves through the prisoners on a 'dolly' – a small railway track – while another is hoisted above them by crane. This is real movie-making, even if the entire budget is only Pounds Sterling 34,000. Homayoun Paiz sits down beside me, 'blood' seeping through a wad of bandages wrapped round his filthy, bearded face. ?I am the hero," he announces. And, I ask – I want my suspicions confirmed – does he die at the end of the film. "Of course," Paiz says. "In the helicopter attack."

We have met before, in the days after the overthrow of the Taliban, when Afghanistan's surviving film community found that the gunmen of the most obscurantist militia in the world had bulldozed a pit in Kabul and used it to burn every foot of film they could find. Paiz's his friends hid original Afghan movies and archive documentary footage, letting the Taliban cremate old Russian and Indian films of which there were copies in Moscow and Mumbai. One of the 'old guard' directors, Siddiq Barmaq, is now himself a leading film-maker and has confronted the US occupation of his country today. His new film, 'Opium Fields', tells the story of two American soldiers who try to escape the country in an old Russian tank – only to find an Afghan family living inside the wreck. The movie has just won the Critics Award at the Rome International Film Festival.

In all, 630 Afghan prisoners – women as well as men -- are believed to have died in the original camp massacre, which lasted for six hours. Some of the prisoners managed to escape and hid in the mountains. Daoud Azimi was one of them and plays an Iranian police guard in the film. What does it feel like to wear the uniform of his oppressors? "I feel good," he says, "because I can actually show the world what they did." We drive back to the broken highway to the east. An American convoy races past us at speed, four-by-fours with blacked-out windows guarded by Humvees, US troops hunched over machine-guns on the roof. Daoud Wahab has plenty of material for his next film. No doubt Homayoun Paiz will play the hero. And die at the end.