The case was first launched by L'Oréal in 2007 when it filed related lawsuits against eBay in the UK, Belgium and France.
It argued that restricting the distribution of its products and preventing them from being distributed would protect consumers from buying counterfeit goods.
L'Oréal complained that eBay "directs its users to goods that infringe trademark law, which are offered for sale on its website". It claimed this includes the practice of purchasing keywords relating to L'Oréal trademarks from paid search services, such as Google’s Adwords.
The High Court of Justice for England and Wales referred questions to the European Court of Justice in August 2009, after it ruled that eBay could not be held responsible for the sale of counterfeit goods.
Today's ruling means that brand owners will be able to initiate legal proceedings against online marketplaces if they play an "active role" in promoting counterfeit goods.
The EU judges ruled that: "National courts now must be able to order those companies to take measures intended not only to bring to an end infringements of intellectual property rights but also to prevent further infringements of that kind."
It said when the operator has played an active role to give it knowledge of, or control over, the data relating to the offers for sale of that kind, "it cannot rely on the exemption from liability which EU law confers, under certain conditions, on online service providers such as operators of internet marketplaces."
It said that national courts are able to order the operator to take measures to end the infringements, and the injunctions made must be "effective, proportionate, and dissuasive and must not create barriers to legitimate trade".
Emily Devlin, IP specialist at law firm Osborne Clark said: "Although there are no outright winners in this case, luxury brand owners will see the ruling as a useful step towards preventing the sale of counterfeit goods via online marketplaces."
They may be disappointed that the CJEU didn't go further and make platforms like eBay responsible for actively policing the way in which their sites are used, but the judgment recognises that would be an impossible task given the scale of these sites."
Stefan Krawczyk, senior director and counsel government relations at eBay Europe, said: "The judgment provides some clarity on certain issues, and ensures that all brands can be traded online in Europe.
"As a marketplace, eBay provides a level playing field for all online sellers and will continue building constructive partnerships to expand the range of brands being sold on eBay."
A L'Oréal spokesman said: "L’Oréal is satisfied with the ruling of the Court of Justice of the European Union rendered today which is a step towards effectively combating the sale of counterfeiting brands and products via the internet.
"The Court of Justice ruled that, as stipulated by trademark laws, national courts must be able to order companies operating internet marketplaces to take measures to prevent the sales of counterfeit products, the sale of unboxed products and not-for-sale products, and the sales of goods imported within the European Union without the consent of the trademark owners.
"This decision is in line with the position L’Oréal has taken for several years and is applicable in courts throughout the European Union."