The Western Cape High Court has ordered that the termination of Patricia de Lille's DA membership by the party was illegal and invalid.
The decision was set aside, and the party ordered to pay the Cape Town mayor's legal costs.
High Court judge Andre le Grange handed down the judgment, which he said was unanimous, on Wednesday.
He said the composition of the DA's federal legal council, which decided on De Lille's fate in the party, was improperly constituted.
There was another reason for the court's decision. It found that, according to the DA's constitution, the panel that made the decision cannot make any adverse finding against any person unless the person has been sufficiently informed of any allegation against him or her, and has been given the opportunity to rebut the allegations and submit evidence in mitigation.
The court found the DA failed to comply with this provision.