The deal highlights a push to toward consolidation the container shipping industry, which has been grappling with low freight rates and oversupply.
It also follows Maersk's announcement in September that it would focus on transport and logistics and spin off its energy operations.
"Hamburg Süd complements Maersk Line and together we can offer our customers the best of two worlds," Soren Skou, chief executive of Maersk Line and the Maersk Group, said.
Hamburg Süd has 5,960 employees in more than 250 offices across the world. Last year, the company's revenue was $6.73 billion and of that $6.26 billion came from its container line activities, Maersk said.
Oetker Group is a family-owned German conglomerate involved in shipping, banking, food and beverages. Market participants had speculated that the Oetker-family would opt to sell its container business.
"Giving up our engagement in shipping after an 80 year-long ownership in Hamburg Süd was not an easy decision for my family," said August Oetker, chairman of the advisory board behind the management holding company of the Oetker Group.
"We are very confident, though, to have chosen the best of all possible partners," he said.
The acquisition will help Maersk Line to boost its presence in global trade, especially in Latin America.
"It's a smaller and more niche player – it's a good strategic fit for Maersk," analyst Michael Jorgensen at Alm. Brand Bank said. He also said the acquisition was a defensive consolidation. Alm. Brand has a "buy" recommendation on Maersk.
Maersk shares were 3.3 percent higher by 0945 GMT (4:45 a.m. ET).
The deal will be the first full acquisition by Maersk since taking over P&O Nedlloyd in 2005.
Maersk said the acquisition would be subject to final agreement and regulatory approvals, and would have no impact on Maersk's outlook for 2016.
A.P. Moller-Maersk said it expected to give more details following approval of the purchase agreement which is expected early in the second quarter of 2017.