Spain hopes to reach an agreement with the UK over Gibraltar by the summer, its foreign minister has said on Friday.
Alfonso Dastis said Spain would "defend our position" but the two sides were "working towards" an agreement as soon as possible.
The UK says "informal" talks are going on about Gibraltar's post-Brexit future with Spain.
Spain has a long-standing territorial claim on Gibraltar, a UK overseas territory on the Iberian Peninsula.
Mr Dastis has previously said that sovereignty would not be an issue in Brexit negotiations.
Instead Madrid wants joint management of Gibraltar's airport and more co-operation on tax fraud and border controls.
Asked if he was hopeful agreement could be reached before October - when the UK and EU hope to reach a Brexit deal that can then be ratified by EU states - Mr Dastis said,: "We are definitely determined to defend our position so I don't exclude anything.
"But we are definitely working towards having an agreement before October, even if possible by the summer, and we hope... that there is also, from the British side, a position which works towards that end."
The EU has said that no future Brexit trade deal may apply to Gibraltar without a bilateral agreement between Spain and the UK.
Mr Dastis said the two sides had met three or four times already this year: "We are having very constructive conversations."
Spain wants joint management of Gibraltar's airport, which is located on a disputed strip of land connecting Gibraltar to the Spanish mainland.
Mr Dastis said that while Spain "cannot accept" British jurisdiction over the land, it wanted to use the airport "to the benefit of the population of Gibraltar".
Asked what joint management would mean, he said: "We will have to work out what the exact terms will be, reports BBC.
"We have tried twice. Once it was rejected by the UK, the second time it was rejected by us - maybe third time lucky?"