By Sarah Nassauer and Georgia Wells

Walmart Inc. said it is joining Microsoft Corp.'s pursuit of TikTok's U.S. operations, throwing a curveball into the chase for the popular short video-sharing app.

The Trump administration has pushed TikTok's owner, Chinese technology giant ByteDance Ltd., to sell its American operations after targeting the app over national-security concerns.

Microsoft's bid is considered the front-runner, according to people familiar with the matter, while a second consortium including Oracle Corp. also remains in the running.

Google parent Alphabet Inc. was also involved in talks as recently as earlier this week, according to people familiar with the matter. Those talks are now dead. Another bid involving Twitter Inc. has also lost momentum, according to some of the people.

The discussions broadly are gaining momentum and a deal could be reached within a week, according to people familiar with the matter.

Walmart's entry into the mix was a surprise even to many people close to the deal talks, and it wasn't immediately clear how a partnership with Microsoft might be structured.

Walmart said it believes a potential partnership with Microsoft would address U.S. government concerns about TikTok. Unlike big tech companies that have been in the Trump administration's crosshairs, Walmart has close ties to the White House.

The retailer's chief executive, Doug McMillon, has traveled to the White House on several occasions, and President Trump has praised Walmart and other big chains for helping with Covid-19 testing efforts during the pandemic.

Walmart and Microsoft are already partners on several technology projects, with the retailer using Microsoft's cloud computing services, as they seek a counterweight to Amazon.com Inc.

"The way TikTok has integrated e-commerce and advertising capabilities in other markets is a clear benefit to creators and users in those markets," Walmart said in a statement. CNBC earlier reported on Walmart's role in the discussions.

"We believe a potential relationship with TikTok US in partnership with Microsoft could add this key functionality and provide Walmart with an important way for us to reach and serve omnichannel customers as well as grow our third-party marketplace and advertising businesses," Walmart's statement said.

Microsoft declined to comment but has previously said it was pursuing a deal for TikTok's U.S. operations and might invite other American investors.

Walmart's shares jumped 6% on the news in Thursday afternoon trading to record highs, approaching a $400 billion market capitalization. The stock price has rallied this year as the big-box retailer has managed to operate throughout the pandemic. Demand from shoppers looking for groceries and household staples has led to surging sales and a jump in e-commerce revenue.

The world's biggest retailer by revenue has been ramping up its online business in recent years, paying $3.3 billion to acquire Jet.com in 2016 and striking a $16 billion deal two years later for a controlling stake in Flipkart, an Indian e-commerce company.

But Walmart, like Amazon, has also looked to move beyond its retail roots, by developing an online marketplace to sell a wider range of products from third-party sellers and smaller merchants. It has also sought to create its own digital advertising network. The company aims to use those services to generate new revenue streams beyond its supercenters, which currently account for most of its more than $500 billion in annual revenue.

Until now, Walmart has mostly used social media to advertise products. But the company has also begun to offer its own digital ad space and access to shopper data, mainly to its existing suppliers. An ownership stake in TikTok could allow Walmart to use the video platform to sell ads to its suppliers -- and potentially to sell its own products through the app.

TikTok, an app that shot to popularity with its videos of dancing and lip-syncing teenagers, has been downloaded more than two billion times since its launch, according to mobile-data research firm Sensor Tower.

As talks of a potential deal have heated up, TikTok CEO Kevin Mayer said this week that he is leaving. The former Walt Disney Co. executive had been on the job for about three months.

--Liza Lin and Rob Copeland contributed to this article.

Write to Sarah Nassauer at sarah.nassauer@wsj.com and Georgia Wells at Georgia.Wells@wsj.com