"We will take legal measures which are proportionate to defend the interests of Spaniards," he said after a meeting with Spain's King Juan Carlos on the Mediterranean island of Majorca.
Increased searches of cars by Spanish border guards have irked Gibraltar, which has accused Madrid of deliberately creating hold-ups in retaliation for the tiny territory dumping concrete blocks in the sea to create an artificial reef.
Madrid has argued that the border checks — which have caused tailbacks of several hours — are necessary to combat smuggling and that the reef is a deliberate bid to impede Spanish fishing vessels in the dispute over territorial waters.
Tensions rose further when Garcia-Margallo suggested Madrid could impose a 50-euro ($66) charge to cross the 1.2-kilometre frontier in either direction, which would affect the thousands of people who make the trip every day.
Spanish officials argue the border checks are needed since Gibraltar is not part of the Schengen area — the passport-free zone of some mainland European countries with open borders.
"We can and should carry out border controls like the ones which we have carried out in recent days," Rajoy said.
The European Commission said on it would send a team of monitors to the Spain-Gibraltar border to ensure that the controls are applied "proportionately".
On Friday Garcia-Margallo told Spain's ABC newspaper the proposed €50 border charge would "never be applied to workers, no matter what their nationality".
He also said any money raised would be used to compensate fishermen who could not access their fishing grounds after Gibraltar's dumping of concrete blocks into the sea to create an artificial reef.
Spain ceded Gibraltar to Britain in perpetuity in 1713 but has long argued that it should be returned to Spanish sovereignty. London says it will not do so against the wishes of Gibraltarians — who are staunchly pro-British.
The internally self-governing British overseas territory, measuring just 6.8 square kilometres (2.6 square miles), is home to about 30,000 people.