When terrorists attacked the upscale Westgate shopping mall in Kenya’s capital inSeptember, they dealt a blow to exhibitors who were already struggling to see B.O. returns. “Suddenly, people got scared, and shopping malls were empty,” says Trushna Patel of Crimson Multimedia, East Africa’s biggest distributor.

The timing couldn’t have been worse. The multiplex at Nairobi’s fashionable Village Market shopping mall had recently closed for refurbishments; another, after years of mismanagement, was looking for a new owner. In a bustling city — the hub of the East African economy — there were just three plexes for more than 3 million people.

The crisis of last fall highlights the broader challenges facing exhibitors and distributors in this nation of 40 million, where a growing middle class presents a potentially lucrative source of ticket sales.

Outside of the capital, there are just two plexes for a vast countryside largely serviced by cramped, tin-roof “movie halls,” which typically screen pirated action movies and kung fu pics for less than a dollar. In Nairobi, the threat of terrorism, crippling traffic jams and a soaring cost of living are obstacles to building a moviegoing culture.

Things looked rosier just over a decade ago, when the country was emerging from the long shadow of dictatorial rule, and the economy was rapidly growing. When Fox Theaters (East Africa) opened its first cinema in 1999, says Anil Kapila, the company’s CEO, it couldn’t keep up with demand.

But the industry was crippled in 2011, when Nigeria’s Silverbird Cinemas pulled out of the Kenyan market after a long-running legal battle with local partners, shuttering four of Nairobi’s six multiplexes. It took more than two years for investors to revive those theaters. “Once you break a habit, it becomes very difficult to get people back,” Kapila says.

Ticket sales plummeted, culminating in the grim weeks after the Westgate attacks. Still, a busy holiday season helped the industry to rebound, with armed guards deployed to reassure theatergoers.

Technology is lowering the barrier for entry into the market, according to Patel, thanks to lower-cost digital projectors. A new theater in Nakuru — a city of 300,000 — will be a test case for the nation’s smaller markets.

Piracy continues to plague the industry. When the Kenya government banned “Wolf of Wall Street” earlier this year on morality grounds, the black market swept in to fill the void. “Pirates were having a field day,” Kapila says. But exhibitors and distributors didn’t see a shilling.