By Aaron Tilley

Merger deals are rarely simple. But Microsoft Corp. Chief Executive Satya Nadella now is attempting to ink a takeover agreement that satisfies not only both the companies and their shareholders, but two governments in bitter competition for technological clout.

If it pans out, the acquisition of TikTok's U.S. operations from Chinese parent ByteDance Ltd. could be a boon to Microsoft's business, giving it 100 million mostly young users to bolster its consumer-facing operations. But the pursuit of TikTok has put the software giant at the center of the U.S.-China firestorm.

Already, Mr. Nadella has been in an unconventional posture for CEO, having talked with President Trump on the phone about the deal on Sunday. Then, in a statement, the CEO took the unusual step of thanking the president for his personal involvement in the negotiations. On Monday, Mr. Trump insisted that part of the purchase price for the deal go to the U.S. Treasury -- a term some observers called inappropriate.

The stakes are high for Microsoft. The company has big business with the U.S. government and last year won a potentially decadelong, $10 billion cloud-computing contract with the Pentagon, which losing bidder Amazon.com Inc. is contesting. Its China business, Microsoft President Brad Smith in January said, represented 1.8% of total revenue, or more than $2 billion a year. The company doesn't break out China sales in its financial filings.

In China, talk of a TikTok sale has gone down badly. The Global Times, a Communist Party tabloid, derided the situation as "the hunting and looting of TikTok by the U.S. government in conjunction with U.S. high-tech companies." One risk for Microsoft is that the Chinese government retaliates over the company's role in a TikTok deal, political analysts have suggested, such as by targeting the Chinese versions of its Bing search engine or LinkedIn, the business-focused social-media platform that Microsoft bought in 2016.

Microsoft has been able to keep those services running in China even as other tech giants have scaled back, in part by agreeing to abide by the Chinese government's censorship requirements. Facebook Inc.'s service is banned in China. Google pulled its search engine out of the country over the censoring of search results.

What has aided Microsoft's relative success in China has been its concentration under Mr. Nadella on selling to business customers rather than trying to tap consumers. "Because Microsoft has been focused on the enterprise, it's been a lot easier for them to operate in China," said Arun Sundararajan, a professor at New York University's Stern School of Business. "The conflict of interest between Microsoft products and what the Chinese government is interested in controlling are minimal."

Microsoft for years has managed to maintain good relations with political leaders in Washington and Beijing. Mr. Nadella hosted Chinese President Xi Jinping at the company's headquarters in Redmond, Wash., in 2015. A year later, the CEO visited Beijing and met political leaders there. Later in 2016, Mr. Nadella and Mr. Smith, who plays a major role assisting the CEO in dealing with Washington, both joined other top executives for a tech summit called by Mr. Trump, then president-elect, making Microsoft one of only two companies, along with Google parent Alphabet Inc., to send two executives.

Since Mr. Trump has taken office, Microsoft has criticized the administration's immigration policies and sought exceptions. But the company also defended its work with U.S. Immigration and Customs Enforcement tasked with implementing those policies, and with the Pentagon after rival Google walked away from bidding on a cloud-computing deal with the military.

Even with its successes, the China market has long posed challenges for Microsoft. Rampant piracy of its Windows operating system and Office productivity apps made it difficult to grow the business.

Microsoft more recently has made progress, convincing the Chinese government to crack down on pirated software, said Paul Triolo, head of the global technology policy practice at Eurasia Group, a political risk consultancy. It also has partnered with China's 21Vianet Group to sell its booming cloud services locally.

In 2017, Microsoft introduced a version of its Windows 10 software specifically for Chinese government use. The customized version included a different type of encryption and other changes. "We have designed Windows to enable the use of local encryption for large public sector customers," the company said, adding it worked with government customers elsewhere to address "issues that matter them."

During the pandemic, the company trumpeted growth in China of Teams, its new product for videoconferencing and collaboration that Microsoft views as its next blockbuster. Between the end of January and early March, Microsoft said it had seen a 500% increase in meetings, calls and conferences taking place via Teams in China.

Microsoft's potential deal for TikTok's U.S. business has drawn heat from some corners in the U.S., too. "Microsoft helped China build its great firewall that is used to surveil and monitor and censor and imprison sometimes the Chinese people." Peter Navarro, the president's economic adviser, said in a Fox News interview over the weekend. "We've got to be really careful about this."

Republican Sen. Marco Rubio of Florida, a longtime China critic, in a tweet, called TikTok's purchase by a U.S. company that secured the data "a positive & acceptable outcome."

-- For more WSJ Technology analysis, reviews, advice and headlines, sign up for our weekly newsletter .

Write to Aaron Tilley at aaron.tilley@wsj.com