“The Square,” a stunning new documentary by Jehane Noujaim about the 2011 uprising in Cairo’s Tahrir Square and its aftermath, epitomizes nonfiction film not just as a way to deepen knowledge and understanding, but also as an art form. In this vibrant, lyrical, graphic, sobering and finally soaring testament to aesthetic and political expression, Noujaim consistently provides light where once there was heat. With lucidity and compassion, “The Square” threads viewers through a complicated thicket of alliances and motivations and, most important, takes them on an immensely moving emotional journey through hope, betrayal, perseverance and surpassing courage.

Considering the sacrifice, pain and bloodshed that has ensued on Tahrir Square since demonstrators first took to the Cairo streets in 2011, it feels bizarre to describe “The Square” as a feel-good film. But that’s exactly what it is, thanks to an amazing cast of real-life characters that Noujaim has assembled to tell Egypt’s political story of the past three years. Taking to the streets first to remove the dictator Hosni Mubarak, then to protest military rule and finally to rise up against the presidency of Mohamed Morsi, the group that has continually returned to Tahrir Square is a loose conglomeration of the many sides of Egyptian society: religious, secular, progressive, conservative, working-class and elite.

Seen through their eyes and related through their often excruciating personal stories, what has often looked like an incomprehensible series of mass demonstrations comes into sharp, urgent focus. The film’s narrator, Ahmed Hassan, is a fiery young man in his 20s who argues until he’s hoarse in defense of the ideals of the Tahrir revolution. The actor Khalid Abdalla, best known for his work in “The Kite Runner,” is the British-educated son of an exiled activist and continually consults with his father on tactics and goals. Magdy Ashour, a member of the Muslim Brotherhood, at first opposes Mubarak because of the historic oppression of his fellow Islamists but comes to question the methods of the Brotherhood once it makes political deals with the Egyptian military. Ramy Essam, a singer who becomes the musical voice of the protests, is a warm, smiling presence who eventually comes under sadistic torture by police forces.

Essam’s wounds are in full view in “The Square,” as are the lifeless faces of victims run over by the military’s tanks, shot by its bullets and otherwise immobilized by brutal responses to the popular uprisings that began with such giddy promise. But just when you think “The Square” is going to offer yet another hopeless portrait of impotent rage and thwarted hopes, it takes an altogether unexpected turn, as Ahmed reminds us that revolution is less about outcomes than about a way of apprehending the world. Filmed on the streets with the protesters — the camera following them into meetings, bedrooms, hospitals and, always, back to the Cairo roundabout that comes to stand for so much — “The Square” puts the audience into the lifeblood and nervous system of a movement that shows no signs of defeat or demoralization.

It’s no surprise that Noujaim, best known for 2004’s gripping “Control Room,” has made a superb film. But even considering the filmmaker’s impressive résumé, “The Square” is altogether remarkable: elegantly shot and structured, but infused with rough, spontaneous energy; global in its consciousness but intimate in its approach; carefully pitched but emotionally wrenching; deeply troubling but ultimately exhilarating.

With Egyptians voting on yet another constitution in the midst of violence and chaos this week, “The Square’s” refusal to succumb to despair is particularly meaningful. Whatever you thought you knew about the country’s contemporary history, see “The Square.” It will astonish you, in all the right ways.

★ ★ ★ ★

R. At West End Cinema. Contains violence and profanity. In Arabic with subtitles. 104 minutes.