The best documentary of the year may also have been the most dangerous to make.

When 50,000 young Egyptians occupied Cairo’s Tahrir Square on January 25, 2011 to protest the fascist regime of Hosni Mubarak, filmmaker Jehane Noujaim (she made 2004’s documentary Control Room, about the broadcast network Al Jazeera) was more than 2,000 miles away, in Davos, Switzerland, awaiting the arrival of Egypt’s leadership at that year’s high-flying meeting of the World Economic Forum. “’If the country erupts and I’m with them there, filming, then that will be an interesting story, because there will be a lot of people in the square with their cameras,’” Noujaim thought. “But of course none of the leadership showed up.”

Noujaim was in the wrong place at the wrong time. It was a mistake she made sure not to repeat. Over the next two-a-half-years, the American-born, Egyptian-bred documentarian shot thousands of hours of footage on the streets of Cairo, capturing each of the revolution’s key moments—the fall of Mubarak; the skirmishes between protesters and the military; the rise of the Muslim Brotherhood; the election and eventual ouster of Brotherhood member Mohamed Morsi; and the subsequent return of the military to power—from the perspective of the intellectuals, Islamists, and young activists who returned time and again to Tahrir Square to make their voices heard.

Noujaim’s new documentary The Square, which premieres Friday at New York’s Film Forum and travels to Los Angeles a week later, is the definitive on-the-ground history of the popular uprising that is still remaking and redefining modern Egypt—a confusing but crucial narrative that America’s dwindling foreign news bureaus were unable to convey with anything like Noujaim’s clarity or coherence. The film is already generating considerable Oscar buzz, and deservedly so.

Watching The Square, you can’t help but wonder how Noujaim and her crew did it. In part that’s because of the deeply compelling “characters” she managed to pluck from Cairo’s massive crowds: actor Khalid Abdalla, the Egyptian-Scottish star of The Kite Runner who became the revolutionaries’ most passionate and articulate spokesman; Ahmed Hassan, a charismatic activist with a huge heart and a fearless intelligence; Magdy Ashour, a kind, bearded Islamist who is torn between his commitment to the Muslim Brotherhood and the ideals of his new secular friends.

But what’s also remarkable are the simple mechanics of making such a risky documentary. How did Noujaim get her cameras into a country in the middle of a military lockdown? How did she film with live bullets flying and teargas canisters skidding across the pavement? How did she keep going after crewmembers were beaten and shot at—and she herself was arrested?

In her most extensive interview on The Square to date, Noujaim discusses all of this and more. “I hope people feel like this film is universal,” she tells The Daily Beast. “It certainly affected me. This whole revolution is a revolution on the outside, but it’s also a revolution on the inside in terms of what you see as possible. When you grow up in a country where you can’t have a political discussion with the guy who’s driving your taxi, and all of that changes, and you watch that process of change and how it works—that changes you inside.”

How did The Square begin? What was the first step?

I grew up about 10 minutes away from Tahrir Square and my family lives in Cairo. My family is Egyptian. So what was happening in Egypt deeply affected me and my family.

When the protests in Tahrir Square erupted on January 25th, 2011, I flew to Cairo as quickly as I could. All of my equipment was confiscated at the airport, but luckily I had bought a Canon 5D camera on the way to Egypt. Friends had told me the authorities were allowing people to come into the country with them because they looked like photography cameras. I got in with that.

About 20 minutes outside the airport, I was stopped by military police who searched my car and found my old film—called Egypt, We’re Watching You, about three Egyptian women fighting for reform—which was not a film that they wanted to see as the country was exploding. So I was questioned for about four hours. I denied, denied, denied that I had ever made a political film, because I didn’t know who was questioning me. I had seen a number of people being blindfolded and taken into other buildings, so it was extremely nerve-racking.

At a certain point I managed to get out to the car—I excused myself to go to the bathroom—and got the DVDs and shoved them down a drain. I went back into the interrogation room, and about five minutes later this guy who was cleaning the bathrooms walks in with a shard of glass, holding it in the air—he’d found the evidence.

I just stopped making excuses. Something in me shifted. I said, “Look, I made a film that I’m proud of about three incredible Egyptian women who were fighting for change. And that’s what the film is about. Please watch it. There are more DVDs in the car.”

When I became truthful and passionate about how I was feeling about the country, something in me changed. It was a small part of what all of the people who went down to the square felt, which was this idea that we’re not going to be silent anymore. That we’re not going to be fearful anymore.

Eventually, the authorities let you go. Your next stop was Tahrir Square. What was your first impression?

I got to the square and was blown away by the spirit and energy that surrounded me. Women, men, all different classes—religious, secular—together having political discussions about their dreams of the future, of a different kind of Egypt. One guy said to me, “I feel so responsible for the country because of what we’ve decided to do. I feel as responsible as a president.” That’s how people felt. They felt like their future was somehow in their own hands. It was this incredible feeling. And I wanted to film it and capture it, so I started looking for characters whom I wanted to spend time with.

Your crew was arrested and shot at and beaten to get this documentary made. What was the scariest moment of making The Square?

The scariest moment for me was when I was arrested at the height of the battle of Mohamed Mahmoud. There had been a ceasefire. We were filming the ceasefire line when some jerk threw a teargas canister in the air. I ran towards the military side, and as I was running, I was thinking, it’s really important to get the military’s perspective on all of this. Because everybody in the military is drafted. How are these kids feeling as they’re shooting at the protesters? Have they been brainwashed? So I started interviewing people on the other side as the teargas was flying.

We did this for about five or 10 minutes and then I figured we should get out of there, so we walked to where I thought the exit should be, but there were rows and rows and rows of Army and police doing exercises.

Suddenly, we were pulled to the side by a military man who spoke perfect English. He was wearing a ski mask. And he looks and me and says, “Your name is Jehane.” Talk about a very strange moment. He said, “Give me your camera,” and took out the film. And then he starts yelling at me in Arabic, using all the buzzwords. We’re surrounded by all of these 17, 18 year-old policemen. “You’re a spy!” “What do you do with your American citizenship!” “Why are you here!” He says this really loudly. I saw the faces of these young policemen around me, and I wondered what would happen if all of sudden they attacked. Would this guy actually have any control? I was not sure he actually did.

Then we were shoved into this big blue police car and “disappeared” for the next eight hours. The charge against me was setting fire to police trucks by throwing Molotov cocktails. [Laughs]

Let’s talk about your characters. How did you meet Ahmed Hassan? He is, of course, a real person—but as a character in a film he is almost too good to be true.

That’s how I felt when I met him. Really. He’s somebody who has a special gift. There’s a kind of magic about him.

Ahmed grew up in a very poor area of Egypt—the slums of Cairo. His father died when he was young, so he grew up taking care of his family and his mother. His mother sold vegetables, and she actually made enough to put him through school—that was always very important to her. So Ahmed and his brother grew up with an education. But he literally sold lemons in the street when he was a kid, and has done every job, from cooking to cleaning, even though he studied journalism in school. The fate of people who studied medicine is often that you’ll end up getting a job as a cabdriver. That was the state of things in Egypt.

Ahmed went to the square when things were erupting, with tear gas, and joined the protest. He was very frustrated with his life. He had gone on a third interview for a job he didn’t get.

When you make a film, you try to find people who are crucial—who need to be shared with the world. With Ahmed, there is nobody you’d rather be with when the army attacks than this fearless guy. I was in situations many times when it was completely dark, the whole place was filled with tear gas. You can’t tell which direction you’re going in. You’re being crushed by a crowd because the army is stampeding in. And out of nowhere I hear his voice shouting my name, and his hand is on my arm and he is pulling me out of the situation.

How about Khalid Abdalla? He was a fairly well-known actor already—the star of The Kite Runner.

Khalid’s father and his grandfather were jailed in Egypt for fighting for political change. So he grew up with an understanding of where Egypt had come from and where it was going. In very confusing times, Khalid manages to articulate, beautifully, what is happening both on an emotional level, with the protesters, and what could be happening on a deeper level, politically.

Perhaps the most fascinating character to me as an American was Magdy Ashour. The Square is not sympathetic to the Muslim Brotherhood, but it is sympathetic to him.

Magdy had not even told members of his own family that he was part of the Muslim Brotherhood until January 25th, because they had been an outlawed, underground organization.

The first scene you see of him, where he says, “I never imagined that I would be here, fighting for change among such a diverse group of people.” He always imagined that it would be a Brotherhood fight. That was the first time that I filmed him. I met him because he was sleeping in a tent right next to all these secular revolutionaries who were labeled the intellectuals.

Magdy would get into these debates about the future of the country with these intellectuals, and they got along very well. It was this beautiful friendship that was beginning to develop, and I could see that a lot of Magdy’s preconceived notions of the other, of the Westerner, of the secular revolutionary, were being changed.

I know you had to go back to Cairo and shoot additional material. Tell me about making that decision.

The first time that we allowed the film to end was with the election of Mohamed Morsi. We were making a film about the political process—the bringing down of a president through the election of a new president. But our characters were deeply unsatisfied when that new president began to take on dictatorial powers and started to make a constitution that was tailored to Brotherhood motivations.

Were you in touch with your characters even after you had “wrapped”?

Oh yeah. We still have our office in Cairo now. Our office is five minutes away from the square. Two weeks before we opened at Sundance, Morsi was grabbing dictatorial powers. Our characters were back in the street, with more passion than ever about this second betrayal. They felt they had to continue fighting against fascism, whether the face of fascism was Mubarak or the military or the Muslim Brotherhood.

So as I was on the way to Sundance I decided that we wanted to continue shooting. To go back to Cairo. It was a difficult decision to make. Everybody thought that we were crazy. We won the audience award at Sundance. Who does that? But this was about our country, so it was very important to get it right. That’s why we went back, and we continued to film. The last shoot was in mid-July.

What surprised you about the revolution? What did you learn by making this film—by being there—that you didn’t know before?

Something that moved me personally and expanded my understanding was just seeing the importance of fighting for possibility, even when you feel like you don’t have any support whatsoever. There were times when I was in the square and I’d be among the protesters, and there were three or four tents in the square. The rest of the country was basically saying, “Why are you still here? The country needs to move forward.” And the protesters were quite resolute that they had to stay there because the secret police were still in power. The military was still in power. There were still random arrests happening.

In the beginning, I would have looked at it like a few people sitting in a square— “how do you actually think that’s going to ever affect anything.” But something happens because those people have stood their ground and stayed in the square. They have created this space that other people can join, and that has the potential to get really big and affect change.

It goes back to what Margaret Mead said: “Never believe that a few caring people can’t change the world. For indeed that’s all who ever have.”

What do Americans get wrong about the Egyptian revolution?

What we’re going through in Egypt is a founding period. It’s not a transition period. I think that’s what a lot of people don’t understand, and without understanding it, it becomes disappointing. People say, “Oh, that leader failed.” But a leader is not going to be successful unless they come out of what Ahmed calls “a state of consciousness.” Tangibly, that means a constitution. A constitution that protects all. So let’s not elect a certain political group before that foundation has been established.

What is next for Egypt?

Look at any big change that’s happened in any country. Look at the civil-rights movement in America. This kind of change takes time, and we need to keep fighting for it. That’s the difficulty with electing someone every four years—we think we elect them and then we go home. If The Square could stand for anything it’s this idea that no, if you bring someone to power—an Obama or whomever—you keep challenging them. You have to keep fighting for these rights continually. I think it’s going to be the same in Egypt. But because I know the people who have been working on the ground —because I have had the deep honor of meeting and filming them—I am optimistic.