A.P. Møller-Mærsk A/S said it would return as much as $1 billion in cash to shareholders through buybacks, as the Danish shipping and oil conglomerate again raised its profit forecast on the strength of its container-transport business.

The Copenhagen-based company said on Tuesday it expects to report full-year underlying profit—which excludes contributions from discontinued operations, impairment losses and divestment gains—of around $4.5 billion, up from a previously raised forecast of $4 billion. Container shipping unit Mærsk Line is expected to earn "significantly" above what it did in 2013, Mærsk said.

Shares rallied Tuesday, rising as much as 5.4% in Copenhagen.

The company's net profit in the three months to end-of-June tripled from a year earlier to $2.25 billion, beating analysts' forecast of $2.1 billion. Revenue rose 2.2% to $11.95 billion.

Mærsk Line, which moves around 15% of the world's containers, reported a second-quarter profit of $547 million, compared to $439 million a year earlier, on a 4.4% reduction in unit costs and a 6.6% increase in container volumes.

Running ships more slowly, known as slow steaming, and the introduction of giant Triple E vessels, which consume an average 15% less fuel than older ships, contained Mærsk Line's fuel expenses. They fell 2.8% to $1.3 billion.

"Stringent cost cutting over the last couple of years combined with the increased volumes, which are higher than the average 5% for the industry, point to a very good year for Mærsk," said Jonathan Roach, an analyst with London-based research firm Braemar Seascope.

Like other shipping companies, Mærsk Line has been hit by weak freight demand at the same time as the industry struggles with overcapacity on the busiest shipping routes. Analysts estimate that overcapacity in the benchmark Asia-to-Europe trade route is at least 10%. If the global economy picks up speed and older ships are scrapped, demand for container ships is expected to grow.

Better use of Mærsk's fleet explained the group's good results, said Chief Executive
Nils Andersen.

"We have had a rather limited development in our capacity and volume growth above 6%," he said. "The large increase in volume is due to the fact that we are competitive but also because the Asia-Europe trade is growing more than the rest of the world trade and we are the biggest on Asia-Europe [routes]," he said on a conference call.

With Asia-to-Europe freight rates still lower from the beginning of the year, Mærsk is counting heavily on a 10-year alliance clinched in July with Swiss-based Mediterranean Shipping Co. to further cut costs, particularly fuel. Industry executives say the so-called 2M alliance will carry around 35% of all goods moved between Asia and Europe, using a combined 185 ships, including 20 Triple-E vessels.

Chinese regulators earlier in the year rejected a wider tie-up, called the P3 alliance, which would have also included French giant CMA CGM, on concerns that the combined strength of the three giants would threaten Chinese container carriers.

"We don't know how CMA CGM will react but we are not being naive and thinking competitors won't do anything," Mr. Andersen said. "They will probably try to engage in other vessel-sharing agreements." Mærsk hopes to have its alliance with MSC up and running in the second half of the year.

Mærsk also benefited from proceeds from the $2.8 billion sale of retailing unit Dansk Supermarked A/S, which offset a $1.7 billion charge on the impairment of its Brazilian oil assets.

The company said it would kick off the $1 billion share buyback program over the next 12 months, while considering further acquisitions of its own stock in the future.