NEW YORK — Shopify, the e-commerce company viewed as a growing competitor to Amazon, is selling the two biggest pieces of its fulfillment network and abandoning its logistics ambitions.

The company announced Thursday in a blog post it will also cut about 20% of its workforce, the second mass layoff its had in less than a year. Last year, Shopify trimmed 10% of its workforce and reportedly laid off dozens of other employees before and after that announcement. The company said Thursday those affected will receive 16 weeks of severance pay and medical benefits.

“There’s no way to make this good news, but we designed a package that will attempt to make it the best possible version of a bad day,” Shopify CEO Tobias Lütke said in the blog post.

Latest NC employment data is ‘bad news,’ says NC State economist Walden

The business changes are also a remarkable reversal after the Canadian company’s multiyear effort to build its own warehousing and delivery services. But investors welcomed the company’s move to focus more on its retail business on Thursday by sending its stocks as high as 17% in premarket trading.

Shopify also said in its earnings report that it pulled in $1.5 billion in revenue for the first quarter, which outperformed Wall Street’s expectations. It reported a profit when analysts had been expecting a loss.

Most of Shopify’s fulfillment assets will be acquired by logistics provider Flexport in an all-stock deal that also includes the sale of the shipping service company Deliverr, the company said Thursday. Shopify bought Deliverr just last year for $2.1 billion.

In exchange, Shopify will receive a stake of about 13% in Flexport, bringing its total ownership in the privately held company up to the high-teens, the company said. Flexport will become the official logistics partner for Shopify, which provides e-commerce tools for merchants. It will also acquire Shopify’s warehouses.

Layoffs help drive up unemployment claims to 242,000

On Thursday, the British grocery-tech company Ocado Group said it was buying another major part of the Shopify’s network – the warehouse automation firm 6 River Systems, or 6RS.

“This is about removing distractions,” said Rick Watson, CEO and Founder of RMW Commerce Consulting. “Long term the right decision, but short-to-medium term it is raises many more questions about Shopify’s management team.”

Shopify’s logistics network is comprised of Deliverr, 6RS and the SFN App, which allows merchant to track shipments.

The sell-offs come as the company based in Ottawa, Ontario, is aiming to cut down on costs amid a post-pandemic slowdown in online shopping and high inflation. The moves will also allow it to offload employees it acquired under the deals.

Shopify is returning to its roots, President Harley Finkelstein said an interview addressing only the Flexport deal.

“Fundamentally, this lets Shopify get back to what we do better than anyone on the planet, which is the retail side of the business,” Finkelstein said.

Meanwhile, Flexport CEO Dave Clark said he believes Shopify is doing “some of the hardest things the leadership team has to do, which is change direction when you learn new information.”

Flexport, last valued at $8 billion, declined to share more information about its financials. But analysts say its valuation has likely gone down in recent months given the tough investment environment.

Even if the company were still valued at $8 billion, Shopify is selling the assets at a loss, given the $2.1 billion it paid just for Deliverr last year. Under the prior valuation, the e-commerce company would get roughly $1 billion worth of Flexport stock.

Shopify and a representative for Ocado Group declined to provide the terms of that deal. A spokesperson for Ocado Group said the transaction didn’t meet the formal disclosure threshold. The e-commerce company had purchased 6 River Systems in 2019 for $450 million.