The prime minister's confirmation follows a statement made by a Reuters source earlier in the day that the deal has been reached.
"Negotiations went on through the night with Spain and Britain. In a telephone conversation just now (European Council President Donald) Tusk and (Spanish Prime Minister Pedro) Sanchez reached an agreement on Gibraltar," the source stated.
The source also confirmed that a EU summit planned to be held on Sunday 'will go ahead.'
In addition, Reuters cited a draft document highlighting that when the UK withdraws from EU, "Gibraltar will not be included in the territorial scope of the agreements to be concluded between the Union and the United Kingdom."
At the same time, British authorities said in a statement that they were willing to hold negotiations with Spain to discuss the future of Gibraltar.
On Sunday, the EU 27 leaders are expected to endorse the draft Brexit deal, including the withdrawal agreement and the declaration on the future EU-UK relations.
Gibraltar, located on the southern coast of Spain, has been a British Overseas Territory since 1713, when Spain ceded it to the United Kingdom under Utrecht Treaty. The region's residents rejected the idea of Spanish sovereignty in 1967 and joint UK-Spanish authority in 2002.
The region is set to leave the European Union together with the rest of the United Kingdom in March 2019. The Brexit agreement between London and Brussels includes a special protocol on Gibraltar.