London (CNN) The UK and Spain reached an agreement Saturday over the status of Gibraltar once the UK has left the European Union.

The accord over the British territory paves the way for approval by 27 EU governments at a summit Sunday on the withdrawal terms of the UK from the bloc next year.

"I have just told the head of state, the King, that Spain has reached an agreement over Gibraltar," Spanish Prime Minister Pedro Sanchez told reporters in Madrid.

He said the agreement excludes the territory from the general negotiation between the EU and UK and "will allow Spain to negotiate directly with the UK over Gibraltar."

Spain "will vote tomorrow in favor of Brexit," Sanchez said.

Read More