KAOHSIUNG, Taiwan—Fallout from Hong Kong’s unrest is galvanizing resistance against China on another front: Taiwan.

Protests in Hong Kong against Beijing’s encroachment have inspired widespread sympathy across the self-ruling island of Taiwan, a longstanding subject of tension in the region that is both claimed by Beijing and supported by the U.S. with arms sales and unofficial political ties.

Sympathies in Taiwan for Hong Kong have transformed the political fortunes of the island’s leader, President Tsai Ing-wen, whose ruling party advocates a Taiwanese identity separate from China and is seen as traditionally pro-independence. She has vocally supported the Hong Kong protesters in her campaign for re-election this Saturday, contrasting herself with her main rival—who is seen as friendly with Beijing—by casting her administration as a bulwark against China’s authoritarian influence.

Ms. Tsai has portrayed the election as a choice between defending democracy and caving to Beijing’s will in return for economic benefits. Her message has resonated with voters, who opinion polls indicate are likely to re-elect her just a year after handing her party humiliating losses in local elections.

The Hong Kong protests are helping to intensify a deep vein of Taiwanese opposition to mainland China, which presents a fresh challenge to Chinese President Xi Jinping’s vision of delivering a strong and unified nation. Beijing has spent decades trying to convince Taiwanese citizens that their economic future depends on the mainland, while using military drills to remind them a forceful takeover of the island remains on the table.