SAN FRANCISCO — Judging from the large bags of colorful Legos on the floor and dozens of plastic base plates piled on tables, this room could have been the activities station for a well-funded summer camp. And the five women and men drifting in and out, slicing open boxes and rooting around for the right size toy bricks, were young enough to pass as camp counselors.

Only the place where they were working is the opposite of summer camp: Alcatraz, the notoriously bleak military prison turned maximum-security penitentiary turned national park. With its banks of small windows and a “gun gallery” for surveillance, this building is where inmates once laundered military uniforms. It’s usually off limits to tourists.

But starting Sept. 27, visitors will be able to see for themselves, spread across the floor, where so many Legos were heading: an ambitious installation by the Chinese activist-artist Ai Weiwei, featuring 176 portraits of prisoners of conscience and political exiles around the world — from the South African leader Nelson Mandela and the Tibetan pop singer Lolo to the American whistle-blower Edward Snowden — composed of 1.2 million Lego pieces. The work is part of an exhibition running through April 26 called “@Large: Ai Weiwei on Alcatraz,” organized by For-Site, a San Francisco producer of public art, in the prison hospital, A Block cells, dining hall and that former laundry building.

Given Mr. Ai’s sharp critiques of the Chinese government and the tireless campaigning for freedom of expression that led to his own imprisonment in 2011, he could have included himself in the group portrait. He did not. But his 81-day detainment, a numbing and mostly solitary confinement, fueled some of the exhibition’s themes, and the seizure of his passport at that time — it was never returned — has shaped the making of this show.