A South African court on Friday largely dismissed an appeal from government and unions to roll back approval for Wal-Mart's $2.4 billion acquisition of Massmart , ending months of uncertainty about the status of the deal.

The Competition Appeal Court shot down the government's request to have the deal re-examined, although it did rule that about 500 previously fired workers should be reinstated.

The ruling is likely to be seen as a victory for Wal-Mart Stores Inc in its plan to expand in fast-growing Africa. It is also likely to soothe local investors, who had feared a retroactive ruling against the deal would tarnish South Africa's reputation as being open to foreign capital.

Finally logic prevailed. Questions about how open South Africa is to foreign investment will still be there, but this ruling is a big positive for its image as an investment destination for foreign companies, said Nic Norman-Smith, a fund manager at Lentus Asset Management in Johannesburg.

It's unfortunate that we had to go through all this, but the right decision was made in the end.

South Africa's anti-trust regulator, the Competition Tribunal, in May approved Wal-Mart's bid for 51 percent of discounter Massmart Holdings with token conditions. That prompted the government and the main service workers union, SACCAWU, to launch separate appeals.

The state's appeal centred on procedural issues during the May hearing, such as government access to Wal-Mart documents and an alleged lack of time for cross-examination.

Neither of these arguments justified the setting aside of the Tribunal decision, the court said in its statement on Friday.

It did rule that 503 previously fired workers should be reinstated and that the union, the government and the merging companies should set up a study on how to ensure that smaller companies can participate in Wal-Mart's supply chain.

The court also rejected proposals that Wal-Mart should be forced to meet targets on local procurement.

We are pleased that the Competition Appeal Court has recognized the public interest issues which were raised by our government, Saleem Mowzer, special advisor to Economic Development Minister Ebrahim Patel, said after the ruling.

A handful of SACCAWU members picketed outside the court where they did the toyi toyi dance made famous during the anti-apartheid struggle.

I think this is something we can welcome on the question of conditions, SACCAWU spokesman Mike Abrahams told reporters. The judgment says they are not satisfied with the conditions that the Tribunal has agreed upon.

A Massmart spokesman said the company welcomed the decision.

Shares of Massmart were little changed after the ruling, up 0.3 percent at 173.01 rand. The benchmark Top-40 index <.JTOPI> was also flat.

(Writing by David Dolan; Editing by Mark Potter)