The Spanish government is likely to agree a bilateral deal with the UK over Gibraltar before October and does not plan to hold Brexit negotiations “hostage” over the territorial dispute, it said on Wednesday.

Alfonso Dastis, Spain’s foreign minister, reported progress in talks with British officials and said he was “optimistic” that a Gibraltar accord would be included in the final Brexit deal. Britain and the EU have both said they hope the Brexit agreement will be signed off by October.

Madrid was granted a veto over the Brexit deal following the UK referendum in 2016, and if it were to use it it could disrupt the 21-month transition period laid out after Britain officially leaves the block in March 2019.

At the time, Mr Dastis’s predecessor at the foreign ministry raised British hackles by eyeing co-sovereignty over Gibraltar as the possible prize of the Brexit process.

But Spain has since rolled back on that aim, and Mr Dastis said yesterday that while Madrid was not relinquishing its territorial ambitions, it would not use Brexit to try and achieve them.