TAIPEI -- Had it not been for the protests in Hong Kong, Wei Ting-Yan might not have flown home from Germany to vote in Taiwan's presidential election on Saturday.

"Without the Hong Kong factor, I don't think so many overseas students or workers would have come back," the 32-year-old student said. "We saw international news every day on Hong Kong and that's why we booked our tickets," he said. He believed that "basically all" his Taiwanese friends studying in Europe made the trip.

Votes of young people like Wei contributed to President Tsai Ing-wen's landslide victory. They identified with her firm stance against China on issues such as sovereignty and democratic values. Ongoing protests in Hong Kong have fomented widespread sympathy in Taiwan -- something Tsai made much of in her campaign.

Tsai's strong and swift rejection of Chinese President Xi Jinping's reiteration last January of the "one country, two systems" formula for Taiwan was well received by young voters. The Beijing-backed Hong Kong government's crackdown on demonstrators in the territory brought the president more support. Though immediate military action may not be imminent, many Taiwanese share a sense of impending threat from China, which considers the island to be a wayward province.

Recognition that both Taiwan and Hong Kong face a common threat has brought the two societies closer than ever before.

Lu Yu-yu is a 20 year-old student at National Taiwan University. On her first visit to Hong Kong about seven years ago, she thought it was "just another place." But when she encountered a huge rally there on Aug. 31 last year marking the fifth anniversary of Beijing's official rejection of universal suffrage to elect Hong Kong's chief executive, which triggered the 2014 Umbrella Movement, she saw the Chinese territory in a different light.

Lu said she first felt Taiwan's relationship change with Hong Kong in 2014, the year the emergent Sunflower Movement forced the Taipei government to scrap a proposed trade deal with China.

"If people in Taiwan and Hong Kong could get rid of the pressure from China, maybe we won't feel so close," she said. Indeed, ties between Taiwan and Hong Kong were previously loose, despite geographic proximity and a common Chinese heritage.

A banner supporting Hong Kong protestors at a rally after President Tsai Ing-wen’s landslide election victory on Saturday. (Photo by Akira Kodaka).

Hong Kong was ceded by the Qing Dynasty in China to Britain in 1842, while Taiwan was a Japanese colony from 1895 to 1945. The only time the two places were under the same master in the past century was during the three years and eight months Japan occupied Hong Kong during World War II.

The return of Hong Kong to the U.K. after Japan's surrender in August 1945 was originally opposed by Chiang Kai-shek's Republic of China, which governed the mainland at the time and had fought alongside the British against Japan. The ROC government eventually backed down after U.S. mediation.

Chiang's Kuomintang government lost to the communists on the mainland and fled to Taiwan in 1949. The following year, Britain recognized Mao Zedong's regime -- much to Chiang's infuriation.

Hong Kong was a hotbed of pro-nationalist and pro-communist restiveness in the 1950s. Provocations peaked in 1956 when 59 people died in riots.

Taiwan did not officially have a delegation in Hong Kong until July 2011, when a semiofficial representative office opened with the endorsement of Taiwan's Mainland Affairs Committee.

President Tsai Ing-wen following her decisive reelection. (Photo by Akira Kodaka)

The seeds of a closer relationship were sown when Taiwan began to democratize, culminating in its first direct presidential election in 1996.

In the mid-1990s, Tsai personally led the drafting of legislation to govern relations with Hong Kong and Macao. Along with a series of constitutional amendments, these democratic reforms enhanced Taiwan as a beacon of freedom and democracy in the Chinese world, as Beijing proceeded to gradually squeeze various freedoms enjoyed in Hong Kong after the end of British rule in 1997.

Tsai wrote on Facebook last June that she was a frequent beneficiary of Hong Kong's freedom to buy Chinese language books including "those not readable in Taiwan." Tsai considered the territory "the place" to buy books with its "liberal atmosphere and modern laws" -- even without full democracy.

This changed after Xi Jinping's rise to power in 2012, and the 2015 disappearances of Causeway Bay booksellers who sold politically sensitive literature. One of the abducted booksellers, Lam Wing-kee, now resides in Taiwan.

"Publishing books is perceived as a dangerous profession here in Hong Kong," Bao Pu, the founder and publisher of New Century Press, told Nikkei after he published a title revealing secret meetings by communist leaders during the 1989 Tiananmen crackdown.

Since hosting open forums on sensitive political issues is no longer possible in Hong Kong, Taiwan has hosted various symposiums, including one last May to mark the 30th anniversary of Tiananmen. Taiwan was chosen "for the obvious reason of the situation in Hong Kong," said Joseph Cheng Yu-shek, a former professor at the Chinese University of Hong Kong who was the event's de facto organizer.

Students belonging to the Sunflower Movement occupied Taiwan's parliament in April 2014 to protest a trade pact with China. © AP

Lin Fei-fan, a former student leader of the Sunflower Movement, is persona non grata in Hong Kong. He and his peers have held regular meetings with Hong Kong pro-democracy activists like Joshua Wong since around 2012. Their most recent encounter was in Taipei in September, but it cannot be reciprocated in Hong Kong. "We are on the blacklist," Lin told Nikkei.

Wong and other senior figures in his Demosisto group are barred from leaving the territory under a court order. One of their number, Lily Wong, was arrested last week at Hong Kong airport on her way to observe the Taiwan election.

Kenneth Roth, executive director of Human Rights Watch, was denied entry to Hong Kong on Sunday without explanation.

"I had hoped to spotlight Beijing's deepening assault on international efforts to uphold human rights," Roth said in a statement. "The refusal to let me enter Hong Kong vividly illustrates the problem." His report on the situation will now be launched in New York on Tuesday.

A protester brandishes an umbrella after Hong Kong riot police fired tear gas in September 2014. © Reuters

As they see freedoms eroded at home, more and more young Hong Kong people have been attracted to Taiwan. Many were among the crowd at Tsai's final rally the night before Saturday's election.

A 23-year-year old Hong Konger who gave her name as Wing went to the event with some Taiwanese friends, and was impressed by the democratic exercise. "Freedom is not easy to keep up," she said.

Chen Wei-chen, 29, one of Wing's Taiwanese companions, told Nikkei: "We support democracy and human rights everywhere -- especially Hong Kong as it is very close to us."

Syaru Shirley Lin, a political economist at the University of Virginia and Chinese University of Hong Kong, said young people in the two places feel increasingly connected, and this has gathered momentum in the past year.

"The older generations in Hong Kong and Taiwan have not formed a platform [because] the natural connection was never there," said the Taiwanese scholar who has lived in Hong Kong for 30 years.

She believes younger people have connected because "they now have a common goal."