A.P. Moller-Maersk A/S said Wednesday it has agreed to buy LF Logistics for around $3.6 billion including lease liabilities, a move that would give the ocean shipping giant a network of warehouses.

Maersk, the world’s largest container shipping line by capacity, has been reaping the benefits of the rattled global supply strains that have pushed up ocean freight rates to record levels this year and caused backlogs at U.S. ports.

It...

A.P. Moller-Maersk A/S said Wednesday it has agreed to buy LF Logistics for around $3.6 billion including lease liabilities, a move that would give the ocean shipping giant a network of warehouses.

Maersk, the world’s largest container shipping line by capacity, has been reaping the benefits of the rattled global supply strains that have pushed up ocean freight rates to record levels this year and caused backlogs at U.S. ports.

It has been using acquisitions to expand beyond ocean freight into inland logistics. It wants to capture a bigger share of the market moving goods between Asian and U.S. ports, and then from ports into warehouses or businesses and even the last mile to a person’s home.

Warehouses in California’s Inland Empire are a crucial step in the U.S. supply chain. Low warehouse vacancy rates in the area combined with port delays are creating a perfect storm of challenges this holiday season. Photo: Sam Rosenthal The Wall Street Journal Interactive Edition

By acquiring LF Logistics, an arm of Hong Kong supply-chain manager Li & Fung Ltd., Maersk gains control of a network of 223 distribution centers across Asia and more than 250 customers globally, according to LF’s website. LF also provides freight forwarding services for retailers, manufacturers and other cargo owners. The Wall Street Journal had previously reported a deal was near.

The deal is expected to close in 2022. It comes less than six months after Maersk bought two e-commerce logistics companies in August—one in the U.S. and one in Europe—for a total of nearly $1 billion. The acquisition of LF would dwarf these deals but the Copenhagen-based company had already signaled its appetite for bigger acquisitions, bolstered by its strong earnings growth.

Maersk reported a profit of $5.44 billion for the September quarter, more than five times the profitit had a year ago when results were weighed down by the economic slowdown resulting from pandemic restrictions. Revenue jumped 68% to $16.61 billion, amid a surge in freight rates.

The LF deal is Maersk’s biggest move so far to boost its inland logistics business which it hopes will eventually bring in half the group’s earnings. At the moment, around 80% of revenue comes from ocean operations.

Maersk is paying more than twice LF Logistics’s value of $1.4 billion in 2019 when Singapore’s Temasek Holdings Ltd. acquired nearly a 22% stake in the business.

Maersk’s top competitor, Geneva-based Mediterranean Shipping Co. on Monday made a $6.4 billion offer to buy the African logistics assets of French-based conglomerate Bollore SE.

If the deal goes through, it will give MSC control of 16 terminals in the Ivory Coast, Ghana, Nigeria and Gabon along with three rail concessions.

France’s CMA CGM SA, the world’s fourth-largest container ship operator, bought in 2019 Swiss-based freight services provider Ceva Logistics AG for $1.7 billion.

Maersk has around 70,000 ocean customers that include U.S. retail chains, car makers, furniture suppliers, electronics makers and clothing importers. But less than a quarter of those customers use the company to move their goods from ports to warehouses and distribution centers.

Maersk signed in early December a four-year contract with British-based consumer products giant Unilever

PLC to manage ocean and airfreight transport.

Maersk’s last big acquisition was the 2017 purchase of Hamburg Süd for $4.2 billion, which consolidated its position as a leader in container shipping.

Write to Ben Dummett at ben.dummett@wsj.com and Costas Paris at costas.paris@wsj.com