Public anger over the bill has driven some of the largest demonstrations in Hong Kong’s history in the past 10 days, throwing the city into a political crisis and forcing its embattled leader, Carrie Lam, to suspend the bill indefinitely and apologize. She has not fully withdrawn the bill, as protesters have demanded.

The bill’s opponents included recent arrivals like Ms. Li, who is among nearly one million people from the mainland who have moved to Hong Kong over the past two decades, increasing the city’s population to about 7.5 million. Many come to Hong Kong not necessarily seeking political refuge, but for schooling, health care and jobs. That influx is part of the reason many Hong Kong residents are frustrated and anxious about their city’s future, and have protested that the new arrivals are overwhelming the city’s public health care, housing and other social services.

Yet Hong Kong has a long tradition of welcoming mainland Chinese seeking refuge. In the late 1800s, the territory was a sanctuary for Sun Yat-sen, the medical doctor who brought down China’s last imperial dynasty. Millions of mainland Chinese fled for Hong Kong in the late 1950s through 1970s in a tumultuous period that spawned mass famine and political upheaval. After the bloody 1989 Tiananmen crackdown on student-led pro-democracy protesters, an underground pipeline called Operation Yellowbird smuggled dissidents to Hong Kong.

“Hong Kong has always been a settlement place for political refugees from the mainland,” said Bao Pu, a publisher and human rights advocate from Beijing, who has lived in Hong Kong and the United States since 1989.