Zwelinzima Vavi was greeted by supporters and loud music.
The high court in Johannesburg on Friday set aside the suspension of Cosatu general secretary Zwelinzima Vavi.
"The decision … is declared invalid … and accordingly set aside," Deputy Judge President Phineas Mojapela said.
Mojapelo reserved judgment last week after hearing argument from counsel for Vavi, the National Union of Metalworkers of South Africa (Numsa), and Cosatu.
Vavi took to Twitter on Thursday saying he would not be at the judgment because his daughter had been in an accident in Queenstown.
"But I have to be in Queenstown for my daughter," he wrote.
?Vavi, Numsa general secretary Irvin Jim and his deputy Karl Cloete attended court proceedings last week, as did Cosatu president Sidumo Dlamini and acting general secretary Bheki Ntshalintshali.
In August last year, Cosatu said Vavi had been put on special leave pending the outcome of a disciplinary hearing relating to his affair with a junior employee.
In July, the employee accused him of rape. He said they had an affair. The woman subsequently withdrew a sexual harassment complaint against him.
Following Vavi's suspension Numsa, an ally of his, lodged an application in the high court challenging the decision.
Vavi then lodged papers to be added as an applicant in Numsa's challenge.
In these, he asks the court to grant him an interim order interdicting and restraining Cosatu from enforcing any decision taken at its central executive committee (CEC) meeting in August.
He wants final relief to review and set aside the decision to suspend him and institute disciplinary proceedings.
Legal teams for Vavi and Numsa argued that delegates at the CEC meeting on August 14 last year had not voted on whether Vavi should be suspended.
Instead the decision was made by a side meeting of presidents and general secretaries.
Karel Tipp SC, for Cosatu, argued that a decision was taken on a majority, as was a long standing practice by the trade union federation.
He had explained that eight of the 16 Cosatu affiliates in good standing were for the suspension, while eight were against it or non-committal.
Under Cosatu's constitution the CEC had the power to dismiss or suspend the general secretary.
Tipp said that assuming the number of delegates within those eight affiliates in support of the suspension all agreed, this would mean that there was a majority and a vote was not needed.
Paul Kennedy SC, for Vavi, disagreed, saying this was not democratic. – Sapa