Microsoft Corp.’s attempt to buy TikTok’s U.S. operations represents the latest step in a careful dance the software-maker has performed to meet the demands of the Chinese and U.S. governments while doing business in both places, a balancing act that has grown increasingly fraught amid the political conflict between the countries.

China hawks in the Trump administration oppose any purchase of the social-media service by Microsoft, which wants the popular app to expand its consumer internet business in the U.S. But the company also wants to maintain its robust business in China, the world’s most-populous country.

Microsoft entered China in 1992, helping to engineer the government's computer systems and installing special versions of Windows operating systems that would comply with the country's censorship controls. Early on, the company launched a massive research operation in China, churning out a feeder system of tech executives who would go on to start or work at many of China's biggest tech companies. The large presence endeared the Redmond, Washington-based company to Chinese officials, who allowed Microsoft to maintain the only major Western-run search engine and social media companies in Bing and LinkedIn, albeit censored versions.