The Cannes Film Festival plans to screen a controversial new documentary on Hong Kong’s 2019 pro-democracy unrest on Friday, courting another film-industry clash with Beijing even as the sector remains heavily reliant on China for box-office success.

Cannes kept its decision to show “Revolution of Our Times” a secret until the last minute. The film, directed by 42-year-old Hong Kong native Kiwi Chow, follows seven characters through the sometimes-violent demonstrations against Chinese authority that rocked the city. It ends with last year’s imposition of a national security law by Beijing to silence dissent.

Earlier this year, Beijing censored Chinese director Chloé Zhao’s Oscar win after old comments she made that were critical of the country resurfaced. Separately, Hong Kong, which recently expanded the powers of its film censors to cover national security issues, didn’t air the Oscars for the first time in decades after a Norwegian director’s documentary on protests in the city was nominated for an award. Even the title of Mr. Chow’s film—the second half of the popular protest slogan “Liberate Hong Kong, Revolution of Our Times”—could anger Beijing and the Hong Kong government, which has called the slogan subversive.

Mr. Chow said he worked largely in secret on the project for two years in a bid to avoid controversy that might derail his efforts. Throughout the process, friends urged him to leave Hong Kong, take his name off the project or at least change the title. He decided against all of that.

“I really don’t want to lose to this fear,” Mr. Chow said.

After the new censorship rules were released last month, Carrie Lam, Hong Kong’s top official, said the changes were necessary because the city’s film inspectors previously had no concept of national security.

“Some of these individual rights and freedoms have to be restrained by law in order to have a civilized society,” Mrs. Lam said. “Is it that easy to step on these red lines and thereby stifle freedom of expression in Hong Kong’s creative industry? I firmly believe it won’t.”

Filming the documentary took Mr. Chow into the thick of Hong Kong’s tumult. He followed characters from hard-core front-line protesters to peaceful backers of the movement through months of action. The 2½-hour film starts with a pivotal demonstration in mid-June 2019 and dives into the fiery, multiday occupation and police siege of a university, where Mr. Chow spent three days and two nights sleeping on the floor of one of the occupied buildings.

He said he was soaked with water laced with chemical irritants from a water cannon and took at least one rubber bullet to his helmet. Long sessions in the editing bay left him emotionally drained.

“There were times when I cried so much I had to stop editing,” Mr. Chow said, speaking in his office in an industrial building in Hong Kong on June 30, 2021, the day after he sent the final cut of his documentary to Cannes. “I had nightmares about being chased down and arrested and beaten by police.”

“Revolution of Our Times,” a 2½-hour documentary on Hong Kong’s 2019 pro-democracy unrest, will be screened at the 74th Cannes Film Festival on Friday.

“Revolution of Our Times,” a 2½-hour documentary on Hong Kong’s 2019 pro-democracy unrest, will be screened at the 74th Cannes Film Festival on Friday.

Photo: gonzalo fuentes/Reuters

Mr. Chow accepts that his film may never be screened in Hong Kong. Months into production, Beijing introduced a sweeping national security law under which local authorities have construed some speech as criminal for advocating secession or the subversion of state power.

The city’s defiant pro-democracy newspaper has shut down, and several of its top executives and editors have been arrested, with police pointing to dozens of articles as evidence of a conspiracy to collude with foreign powers. The government has said the actions were to defend national security and have nothing to do with freedom of the press.

Hong Kong movie theaters have recently canceled the screening of a documentary about pitched battles on a campus during the 2019 protests and another about the legalization of same-sex marriage in Taiwan.

These political pressures have added to commercial ones long weighing on Hong Kong’s vibrant film industry, which in its heyday produced global stars such as Jackie Chan as well as celebrated directors like Wong Kar-wai and Johnnie To. Some independent films about the city’s politics have managed to thrive in recent years, but critics say the remaining space for untrammeled voices in cinema is quickly disappearing.

Mr. Chow is known in Hong Kong as one of the directors of a dystopian anthology of five short films called “Ten Years,” which won best picture at the city’s top film awards. Released in 2015, the package imagined what Hong Kong would be like in 2025 after a decade of further encroachment by Beijing.

At the time, some viewers felt the films exaggerated the pace of China’s crackdown. But they also foretold some of the trouble. In one of the five shorts, called “Self-Immolator,” directed by Mr. Chow, Hong Kong is rocked by pro-independence riots in a fictional 2020.

Mr. Chow said he had an urge to document the most recent pro-democracy protests but initially felt timid about heading to the front lines. Out of the blue, a businessman who had seen “Ten Years” called him up and offered to back a high-quality documentary that would help Hong Kong tell its story to the world. Mr. Chow bought a hand-held camera and began filming.

His collaborators on the film, including editors and photographers, have since kept their names hidden or stopped working with him. But he insisted on attaching his own name to the film publicly, he said, to combat self-censorship and to signal that the film should be a lawful one under free-speech protections.

Mr. Chow submitted an early version of the film to Cannes this spring. After learning it would get a special screening, he braced for the fallout and as a precaution sent all his footage out of Hong Kong. He said a major investor in a new film he is preparing for has already pulled their money, fearing any association with him could bring unwanted scrutiny.

The filmmaker said he has tried to tune out concerns about what he could and couldn’t say in order to stay true to his vision.

“I don’t want to speculate where the red line is,” he said. “Only then can I be free.”

The red carpet at the main entrance of the Festival Palace in Cannes, southern France.

The red carpet at the main entrance of the Festival Palace in Cannes, southern France.

Photo: john macdougall/Agence France-Presse/Getty Images

Write to John Lyons at john.lyons@wsj.com and Elaine Yu at elaine.yu@wsj.com