It was the road in front of the army headquarters — a building which also served as a British military installation — where Ms. Yau’s transformation began two years ago, on Sept. 28, 2014. It was there and then that she first experienced the political life: joining thousands of people in a standoff against the police.

As remarkable as Ms. Yau’s rise from office worker to radical lawmaker may seem, her personal transformation is far from unique here. She is just one of hundreds of thousands of Hong Kongers whose lives were altered by the pro-democracy protests that swept the city two years ago.

A generation of young people forged their political identities as they rallied — ultimately unsuccessfully — against China’s decision to put strict controls on planned elections for the city’s chief executive. To them, it was a betrayal of the promises made more than a generation ago that led to Britain transferring sovereignty to China, with the promise that Hong Kong would enjoy a high degree of autonomy until at least 2047.

“All of us had the same mission, that we had to stop the government and try to get our democracy,” Ms. Yau said in an interview.

After a few days, she became disillusioned with the main body of protesters who had set up camp on the thoroughfares around the Legislative Council building and the main government offices. The atmosphere was like a “festival,” she said.

“When I came out from my home I thought I had to fight, to have a war with the government,” Ms. Yau said.

When the protests ended after 79 days in December 2014, most participants resumed their daily routines. But not Ms. Yau. She volunteered for the newly formed Youngspiration party and ran for a seat in a local district council in 2015. She lost, but was spurred to run for the legislature after violent clashes broke out in February.