The memoranda of understanding outline cooperation in the fields of tobacco smuggling, policing, workers' rights and the environment, setting up joint committees that will meet to exchange information.
This only applies to the transition period until the United Kingdom actually leaves the European Union, but nevertheless represents a boost in relations between Spain and Gibraltar, a British overseas territory long claimed by Madrid.
"The memoranda reflect our shared desire to work together in a spirit of trust and solidarity," the British government said in a statement.
They do not however touch on the thorny issue of sovereignty.
Spain has a long-standing claim on Gibraltar, a small rocky outcrop on Spain's southern tip that it ceded to the British crown in 1713.
Gibraltar, however, wants to maintain its ties with the United Kingdom.
Relations between Spain and Gibraltar have long been strained and this has been reflected in the small land border between the two.
In one particularly belligerent row over disputed waters, Spanish authorities upped border checks in 2013, creating hours-long logjams and forcing the European Commission to intervene and ease the crisis.
But Brexit forced the governments of Spain, Gibraltar and Britain to the negotiating table on many long-standing issues.
Under the accords, Gibraltar has agreed to increase the price of tobacco products in an effort to attack contraband trade.
Prices are currently between 25 and 48 percent lower than in Spain, depending on the products, according to the government of Gibraltar.
The deal says that "by June 30, 2020, the average retail price differential of tobacco products will be no more than 32 percent greater than the most recently published Spanish prices for the equivalent tobacco products."
Another memorandum sets up a joint Spain-Gibraltar committee for police and customs cooperation, another for workers' rights and another on environmental issues, with each side having an equal number of members.