‘Just what our country needs!” rails the imam sarcastically on Libyan TV. “A women’s football team! And what’s more, they chose tall, young beautiful girls for the team – and for months their legs will be exposed.”

Women’s football may be getting its moment in the spotlight with the World Cup about to kick off. But, as the absorbing new documentary Freedom Fields reveals, the Libyan women’s national team has some way to go. As well as that imam, the film also features this statement from extremist group Ansar al-Sharia: “We strongly refute what the supporters of immoral westernisation are doing under the pretext of women’s freedom. This might lead to other sports with even more nudity, such as swimming and running.”

The edict is read aloud by one of the armed guards who must accompany the team at their training sessions, which take place at secret locations. This was in 2013, just a couple of years after the revolution that brought Muammar Gaddafi’s reign to an end. It seemed to promise a new era of democracy and freedom – including women’s freedom to play football.

“That period was really joyous,” says director Naziha Arebi, who began making Freedom Fields then. “Everyone thought stuff was going to happen. The women thought they would now get to play. I thought they’d have their first match, and I would film that beautiful thing, that struggle.” Her voice tails off.

Tool for change … a scene from Freedom Fields. Photograph: Chicken & Egg Pictures

The story didn’t pan out that way – for Libya, for the football team, or for Arebi’s film. That feeling of optimism descended into a chaotic civil war that continues to this day. Arebi had imagined her film ending with the underdogs kicking their way on to the international stage, but it was not to be. She stayed in Libya, though, and spent the next five years following the team’s trials on – and more often off – the pitch.

“I was attracted to all these brilliant characters,” she says. “So I stuck with them, even when there was no football going on.” It might not culminate in a nail-biting penalty shootout, but her film captures the hopes and frustrations of an entire country. It is a far more substantial work.

The women’s national team existed in the Gaddafi era, but it received barely any support. Libya is not the most restrictive state in the Arab world, but it still runs along conservative, patriarchal lines. Tripoli comes to a standstill when the men’s national team plays, but women tend to be told they should be getting married and raising families rather than playing football. It is certainly not regarded as something that could be a woman’s full-time job.

In the film, we meet goalkeeper Halima, who works as a pharmacist and has pictures of Libyan midfielder Tarik El Taib and Barcelona forward Lionel Messi on her bedroom wall. She is engaged to be married. “So far,” she says, “everyone who got married had to quit playing.”

‘People still go to the beach when there’s fighting on the other side of town’ … film-maker Naziha Arebi. Photograph: Rex/Shutterstock

Even when not being personally targeted by religious extremists, these women have to cope with the chaos and insecurity of everyday life in Libya. Power cuts are a constant in Freedom Fields. At one stage, the floodlights cut out during a night-time practice and the team must illuminate the pitch with their car headlights. Other recurring features include plumes of black smoke on the horizon, litter-strewn wastelands and the sound of distant gunfire.

“You get used to it,” says Arebi. “People still go to the beach when there’s fighting on the other side of town, or you’ll be in a coffee shop and you’ll go, ‘What was that, fireworks or gunfire?’ It’s not that people are desensitised, but if you live in fear, then they’ve won. So for a lot of people, it’s a form of defiance.”

Little moments of freedom … a girl plays in a Libyan street. Photograph: Freedom Fields

I first met Arebi when I visited Libya in 2012 to write about the country’s first steps in film-making following the revolution. She was born and raised in Hastings, to an English mother and a Libyan father. He never taught her Arabic as a child, she says, but he did take her to Arsenal matches. She first visited Libya in 2010, before the revolution, to reconnect with her family. “I came back covered in henna,” she laughs. “I got really hooked into that side of my culture.”

Having studied film at Central St Martins in London, her plan was to work on feature films. “I was into making stuff in the style of Mike Leigh, developing stories organically,” she says. When she moved to Libya permanently in 2011, she found a host of true stories waiting to be told.

Leigh attended a screening of Freedom Fields at the London film festival last year. “I was so overwhelmed” says Arebi, but she did manage to exchange a few words with him. “He said he wanted more football – and I was like, ‘But they didn’t get much football, so you don’t get much football.’”

Being a female film-maker in Libya brought its own obstacles. “It’s definitely something women don’t traditionally do,” she says. But there were advantages. “Sometimes, when I got in difficult situations, it was easier to negotiate with armed groups or people trying to stop filming, because they didn’t see me as such a threat.” In the early days post-revolution, people were happy to be filmed, Arebi says, but as the situation worsened, officials grew cagier and permissions became harder to obtain. “But, for every person that wants to stop you, there’s somebody that wants to help you.”

One of the most striking things about the film is the contrast between the women’s behaviour within their homes and during their times together as a team. Class, political and cultural differences disappear: they sing, joke, argue – and play. “We come to know these women as people: spirited, determined, resilient and very funny,” says Arebi. “Their happiness at being a part of something is palpable.”

In a country where homes often have separate men’s and women’s lounges, the pitch is one of the few communal spaces where women can express themselves physically. “For them,” says Arebi, “it wasn’t necessarily about being this amazing national team. It was about playing and wanting to be good at it, of course, but also being among like-minded people and having a little moment of freedom.”

They’ve busted the barriers of political and class differences. They’ve also become pretty strong and kick-ass

The Libyan team won’t be appearing at the Women’s World Cup. They currently have no Fifa ranking, although they have played a couple of international matches, against Ethiopia and Egypt. They lost 8-0 both times. The players in Freedom Fields are no longer part of the squad: some of them have founded their own NGO, using sport as a tool for trauma relief, reconciliation and female empowerment. They’ve also accompanied Arebi to screenings.

“It’s not about the football,” says Arebi. “It’s about using football for other gains. Through sport, they’ve busted those barriers of political and class differences. They’ve also become pretty strong and kick-ass. For them, it’s about giving that to the next generation.”

As for the next generation of Arab and women film-makers, Arebi is a beacon of hope. She has been producing another Libyan documentary over the past six years, following a brother and sister who fought on opposite sides of the revolution. And she’s writing a Libyan family comedy, so she could yet be the country’s answer to Mike Leigh. She has also been “on a mission” to bring together a community of film-makers in the country. Revolution is one thing, she has learned, but sustainable change is a slower, more difficult process. And despite the chaos, there seems to be no better time to be working.

“It’s important that we comment on these times and tell our own stories,” she says. “We can’t wait till this mess is finished, because we might be waiting for ever.”

• Freedom Fields is out now.