The judgment was handed down 10 days before India holds a general election, in which the ruling Congress party and the opposition Bharatiya Janata Party (BJP) will go head to head in a contest where corruption is one of voters' top concerns.
Sterlite Industries India and Sesa Goa, two companies then registered in India but whose controlling shareholder was Vedanta, donated 87.9 million rupees in total to Congress between 2004 and 2012, according to data gathered by the anti-corruption group that brought the case.
Sesa Goa donated 14.2 million rupees to the BJP over the same period, according to the data gathered by the Association for Democratic Reforms (ADR) and presented in court. The ADR brought the case against the two parties, and not the companies.
Sterlite Industries India also donated 70 million rupees to the BJP, according to the company's annual 2009-10 report. Vedanta, which is the controlling shareholder, merged the two companies last year.
"The acts of the respondents ... clearly fall foul of the ban imposed under the Foreign Contribution (Regulation) Act, 1976 as the donations accepted by the political parties from Sterlite and Sesa accrue from "Foreign Sources"," Judge Pradeep Nandrajog and Judge Jayant Nath wrote in their judgment.
The court directed the home ministry and the election commission to investigate all donations to the parties by the two companies, as well as from any other groups with similar ownership structures that would also be deemed "foreign sources", and act within six months.
The government can prosecute people under the Foreign Contribution (Regulation) Act. Party officials and lawyers who facilitate such transactions can be jailed for up to three years for violating the laws on foreign donations.
Lawyers for Congress and the BJP had argued that the donations could not be classed as foreign partly because the two smaller companies were registered under India's Companies Act and partly because Vedanta's largest shareholder is billionaire Anil Agarwal, an Indian citizen.
Pinky Anand, a BJP member and lawyer for the case, said the party would appeal against the ruling using those arguments.
"Frankly, what is the objective of this law" Anand added. "It's to prevent illegal money coming in, not legal money coming in. This money has been declared, it hasn't walked in."
A Congress party spokesman said the funds were received "from an electoral trust by an Indian company based in India".
"There has been no violation," said the spokesman Sanjay Jha but added that they would study the court order.
The party has been at the helm of India's coalition governments since 2004, although it is widely expected to be defeated in the upcoming elections.
Vedanta's legal head, Ajit Yadav, did not respond to requests for comment. The company's stock gained 0.3 percent in London trading at 886 pence.