Germany’s top court has overturned a federal law that prevented foreign companies from profiting from renting out private cars.

The ruling by the Constitutional Court of the state of Baden-Württemberg (Baden-Essen) on Thursday overturned a ruling by a lower court in February that had banned such companies from charging for the use of car rental agencies.

Lawmakers in the state had passed a law in September that banned such arrangements, which were common in Germany.

“This law violates the constitutional right to freedom of speech, freedom of association and the right to housing,” the court said in its ruling.

Foreign companies and governments could still refuse to rent cars to German citizens.

In a statement, the German Association of Hotel Agents (DASG) said it was “disappointed” by the ruling.

It had sought an appeal to the constitutional court.

German car rental firms offer a wide range of services, from hotels to car hire companies.

They also provide car rental services to other countries.