The European Court of Justice dismissed an appeal from Spanish cycling company Massi and the EU's intellectual property office, EUIPO.
The Barcelona footballer first applied to trademark his surname as a sportswear brand in 2011.
But Massi argued the similarity between their logos would cause confusion.
The European Court of Justice (ECJ) said that the star player's reputation could be taken into account when weighing up whether the public would be able to tell the difference between the two brands.
In doing so, it upheld a ruling by the EU's General Court in 2018 that the footballer was too well known for confusion to arise.
Massi, which sells cycle clothing and equipment, was successful in its initial challenge to the Barcelona striker's application. But it lost out when Lionel Messi brought an appeal to the General Court, which ruled in his favour.
Messi, 33, who wears the number 10 shirt, has been crowned world football player of the year a record six times and is the world's highest-paid soccer player, according to Forbes. It puts his total earnings for 2020 at $126m (£97m).
In August, he made headlines by sending a fax to his club declaring his intention to leave.
But when Barcelona responded by insisting that any team that took him on would have to honour a €700m (£624m) release clause, he changed his mind, saying he did not want to face "the club I love" in court.