The EU said last year Madrid and London must make a separate bilateral agreement for any overall Brexit deal to apply to the rocky British territory.
Gibraltar has been under British control since 1713 but Madrid has long wanted it back.
"We have already started bilateral talks with the United Kingdom," Rajoy told reporters in Brussels after EU leaders approved guidelines for the next phase of Brexit negotiations.
"These are progressing satisfactorily" and "we hope to reach an agreement in the coming months," Rajoy added.
Earlier this week Spain threatened to torpedo an agreement for a 21-month post Brexit transition period unless the EU made a specific mention of Gibraltar in new guidelines for trade talks due to start next month.
Rajoy said he was aiming for a deal which would "firstly ensure that the situation of frontier workers is maintained and improved, which is our priority, and reasonable solutions to a number of issues which have been adversely affecting" Gibraltar.
The 27 EU states, without Britain, approved a clause last year that "after the United Kingdom leaves the Union, no agreement between the EU and the United Kingdom may apply to the territory of Gibraltar without the agreement between the Kingdom of Spain and the United Kingdom."
Britain was infuriated, saying that it infringed on its sovereignty over "the Rock".
Rajoy however said that "in the talks on Gibraltar, the issue of sovereignty is not going to be dealt with".
Every Thursday we'll deliver a free dose of news and views from Spain straight into your inbox. The newsletter will inform you about what's going on in Spain and (hopefully) entertain you with a selection of features. Sign up here.