"We can confirm that any tax (or) fees imposed at the border of a member state will be illegal under EU law," Commission spokesman Olivier Bailly told a news briefing in Brussels.
Spain's Foreign Minister Jose Manuel Garcia Margallo had suggested in a media interview at the start of August that a €50 tax would be levied for travellers entering Spain from Gibraltar.
The idea provoked outrage amid a growing row around the tiny British outpost at the tip of Spain.
Bailly was answering a "theoretical" question from a journalist, on the day British warship HMS Westminster docked in Gibraltar in a naval exercise coinciding with escalating tensions over sovereignty and fishing rights.
The Commission's reminder of EU law came a day after dozens of Spanish fishing boats sailed to waters around Gibraltar to demand it remove 70 concrete blocks it has dropped in their fishing grounds.
Commission head Jose Manuel Barroso was to speak by telephone with Spanish Prime Minister Mariano Rajoy on Monday, Bailly also said, after the EU leader held a similar conversation with British Prime Minister David Cameron on Friday.
The purpose of the call was threefold, he said: to "listen to what these two leaders have to say"; "to reassure that the Commission will act as necessary to ensure EU law is fully respected by both countries"; and to bang heads together to ensure a "proper dialogue" between the two capitals so as to "find an adequate solution."
The self-governing British overseas territory of Gibraltar measures just 6.8 square kilometres (2.6 square miles). It is home to about 30,000 people.
Spain has imposed intense customs checks at the land border, which British Prime Minister David Cameron has described as "politically motivated".
A Commission inspection team is to travel to the border in September to verify that these border checks are legal.