BioNTech on Monday announced a deal to provide 10 million doses of its coronavirus vaccine to Taiwan, easing a serious shortage there and ending months of deadlock stemming from the self-ruling island’s complicated relationship with China, which considers Taiwan part of its territory.

The deal is a convoluted one, reflecting the delicate needle that had to be threaded.

The vaccines will be purchased, then donated to Taiwan’s government, by two of the island’s most prominent corporate titans — conn, a major assembler of Apple’s iPhones; and TSMC, which makes the cutting-edge chips in Apple’s latest devices — in conjunction with the YongLin Foundation, a charity set up by conn’s founder, Terry Gou.

The shots will be sold by Fosun Pharma, the Shanghai company that is BioNTech’s manufacturing and distribution partner for mainland China, Hong Kong, Macau and Taiwan. (BioNTech’s partner in other parts of the world, including the United States, is Pfizer.)

And officially, the buyer will be Zuellig Pharma, a Swiss-owned company entrusted with the task by conn, TSMC and YongLin. The New York Times reported last month that discussions had taken place about a deal that would include Zuellig, which is already working with Moderna to supply that company’s coronavirus vaccine in Southeast Asia, Hong Kong, Macau and Taiwan.

For much of this year, it looked as if Taiwan’s efforts to acquire vaccines from BioNTech, a German company, had fallen victim to political tensions with China. Taiwanese officials said that they had negotiated with BioNTech for months before unspecified “Chinese intervention” caused the talks to run aground. Officials in Beijing denied this and said that, given BioNTech’s partnership with Fosun, Taiwan should not have been dealing directly with the German drugmaker in the first place.

Chinese officials have offered to donate vaccines made by Chinese companies and said that Taiwanese people were welcome to get inoculated in China. But Taiwanese law bars the import of Chinese-made vaccines, and opinion polls show that many people in Taiwan distrust them. So far, the island has administered first vaccine doses to around 15 percent of its 23.5 million residents. Many of those shots were donated by Japan or the United States.

conn, TSMC and YongLin sought to reassure the Taiwanese public in a joint statement on Monday, saying that the BioNTech vaccines they were buying would be imported directly from factories in the European Union and would bear the original labeling. The shots are expected to arrive at the end of September at the earliest, the statement said.

Mr. Gou of conn wrote on his Facebook page that the government in Beijing had not steered the purchase or interfered in it at all.

Taiwanese health officials expressed their gratitude for the deal on Monday. A spokesman for China’s Taiwan Affairs Office also praised the agreement, though he added that if the island’s government “had considered the life, health and well-being of Taiwan compatriots, this issue could have been resolved sooner.”