Tanzania has banned traditional African hospitality known by its Swahili name of "takrima" during election campaigns.
Campaigners argued takrima was not limited to free food and drink
Under the country's electoral law, politicians were allowed to hand out food and drink to prospective voters.
But the High Court ruled in favour of three legal rights organisations that argued it was a form of corruption.
The BBC's Emmanuel Muga in Dar es Salaam says it is a blow to the government that legalised takrima shortly before the 2000 polls.
The three High Court judges ruled unanimously that the practice should be outlawed, our correspondent says.
Celebrating the landmark ruling, the legal rights organisations said as well as being unfair to politicians who could not afford to provide it, the hospitality was not limited to free food, drink and transportation.
"Takrima is a technical term which has been invented by the people who were in power to help them cling to power," one of the challenging lawyers, Julius Mashamba of National Organisation for Legal Assistance, said.
"During general elections it was observed that most of the candidates were providing a lot of things, including money, which influenced the electorate," he told the BBC's Network Africa programme.
In general elections last December, described by international observers as well run, Tanzanians overwhelming chose ruling party candidate Jakaya Kikwete as their leader.
He took over the presidency from Benjamin Mkapa who stepped down after two terms.
Turnout was 72% of the registered voters with 11.3 million votes cast.