JOHANNESBURG, South Africa — Attention African shoppers: Wal-Mart is coming.

South Africa’s antitrust commission ruled Tuesday that the American behemoth retailer can acquire a $2.4 billion, 51 percent stake in Massmart, a Johannesburg-based retail group with stores across the African continent.

The takeover deal marks Wal-Mart’s first foray into Africa and highlights the growing importance of Africa’s emerging market of middle-class consumers, against a backdrop of stagnant markets in developed economies.

Wal-Mart hopes to use Massmart as a steppingstone into sub-Saharan Africa, and is looking to appeal to the growing purchasing power of Africans with its low-cost goods.

Significantly the Wal-Mart/Massmart deal is a perception changer for Africa. News of the deal drew a mainly surprised response on GlobalPost’s Facebook page, with American commentators expressing a “wow, really?” reaction to the fact that Wal-Mart, the world’s largest retailer, would be coming to Africa.

Africa is increasingly being viewed as a booming dynamo, following in the footsteps of Asia’s impressive economic growth — and no longer seen only as a continent of war, famine and misery. These changing perceptions of the continent are being led by foreign businesses that see the potential for growth.

Wal-Mart says that it will create new jobs in South Africa and provide "previously underserved customers and communities with better prices and increased access to the products they want and need."

“The combined Wal-Mart/Massmart entity is planning significant new store openings, which will create thousands of new union jobs in South Africa,” Wal-Mart International CEO Doug McMillon said in a statement.

Massmart owns 290 stores in 13 African countries, including the chains of Game, Makro and Builders Warehouse.

But Wal-Mart’s takeover of Massmart — its biggest acquisition in more than a decade — was almost blocked by South Africa.

The approval of the South African Competition Tribunal was required for the deal to proceed. But at hearings in Pretoria in May, government departments and South Africa’s powerful labor unions strongly opposed the takeover, arguing that Wal-Mart will flood the market with cheap imports, kill jobs and hurt local businesses.

COSATU, the main umbrella group for South African unions, demanded that the tribunal block the deal, warning of thousands of potential job losses. The group argued that Wal-Mart is "anti-union," and threatened protest action.

The competition tribunal only allowed the deal to go ahead subject to a number of conditions “to protect the public interest,” including the requirement that no jobs be cut for two years.

Furthermore, the companies must ensure that existing labor agreements are honored for three years after the takeover, and that $14.6 million is invested in a fund to help develop local suppliers.

All of these conditions had been proposed by Wal-Mart and Massmart on the last day of the hearings, a sort of peace offering to help the passage of this contentious deal.

In a country with 25 percent unemployment — that’s the official rate; it is as high as 40 percent when discouraged jobseekers are included — jobs are a key issue and a source of frustration among many young South Africans. President Jacob Zuma’s administration has promised to will create 5 million new jobs by 2020.

A particularly contentious issue during the hearings over the Wal-Mart takeover was the plight of 500 Massmart workers that were laid off last year. Union leaders argued that the layoffs had occurred in order to make Massmart a more attractive target for acquisition by Wal-Mart.

In its ruling released Tuesday, the competition tribunal said that there was "no conclusive evidence" that the layoffs were related to the merger, but that the laid-off workers will be given preference for job vacancies.

Now that the deal has approval, the antitrust authorities must publish the full reasons for their decision within the next 20 days. If any of the parties are unhappy with the ruling, they can still appeal to South Africa’s Competition Appeal Court.

Wal-Mart has announced that it plans to close the deal with Massmart in a matter of weeks.