Judge Willem van der Linde ruled at the South Gauteng High Court on Friday that Tau's 2016 comments defamed Mashaba.
Speaking at a funeral of the late ANC councillor Nonhlanhla Mthembu, Tau made remarks implying that Mashaba was sexist and anti-black.
At the funeral, Tau said: “The City of Joburg is today led by a man who believes that women who are senior executives prostituted themselves to be in the jobs they are in. He says that in fact for them to earn the positions they are in they had to sleep with the leadership.
“We have heard views from mayor Herman Mashaba who says that in fact if it were up to him, he would not want to be black.”
Ruling in Mashaba's favour, Judge Van der Linde said Tau's defence of his comments did not hold water.
Tau maintained before court that he was reacting to Mashaba's comment that he would purge officials who had been wrongfully appointed.
In his words, Mashaba said: “If the wrong people are in the wrong positions, they are going to be purged. The days when they allowed their girlfriends to run state institutions are over.”
Judge Can der Linde said Tau's defence was flawed and that Mashaba largely accused the ANC of nepotism.
“The implication is clearly that, at least potentially, they (the ANC leadership) could have filled senior female positions in the city with persons with whom they could have had close relationships.
"The applicant (Mashaba) had thus accused the party of his predecessor of nepotism in the appointment of senior females.
“But, as I see it, it is one thing to accuse someone of nepotism; that is bad enough,” the judge said.
“It is quite another though to accuse a person in leadership position of believing that the beneficiaries of the nepotism were not merely friends or family, but were women of loose morals of the most reprehensible kind.
“(Tau’s) statement accordingly does not qualify as fair comment, and defamation has been established.”
Mashaba said o Sunday that now that it had been established that Tau defamed him, he would proceed with his R2m lawsuit.
“Should I succeed in my defamation lawsuit I will donate those proceeds to an organisation supporting women in need in Johannesburg,” Mashaba said.
Judge Van der Linde also ruled that Tau defamed Mashaba by saying “in fact if it were up to him he would not want to be black”.
In court, Tau relied on Mashaba's comments questioning why he was still classified as black and his comments dismissing black economic empowerment as racist.
Tau was ordered to retract his comments and apologise to Mashaba.
He would also have to pay Mashaba’s legal costs.