BRUSSELS (Reuters) - Spain is set to take over Britain’s command of an EU maritime mission that combats Somali pirates next year as Madrid seeks a bigger military role after Brexit, EU diplomats and officials said.

FILE PHOTO: A member of staff works at the Joint Operations Centre and Maritime Security Centre Horn of Africa during a media briefing at the EU NAVFOR Operations Headquarters at Northwood in north west London February 20, 2012. EU NAVFOR Somalia - Operation ATALANTA's main tasks are to escort merchant vessels carrying humanitarian aid of the 'World Food Program' (WFP) and vessels of 'African Union Mission in Somalia' (AMISOM), and to protect vulnerable ships in the Gulf of Aden and Indian Ocean and to deter and disrupt piracy. REUTERS/Luke MacGregor/File Photo

Under the deal, Spain has also offered to help Italy in dealing with migrants crossing the Mediterranean, they said.

European Union foreign and defense ministers are expected to back the decision on Monday to hand command of the Atalanta mission off the Horn of Africa to Spain, with support from France, when Britain leaves the bloc in March.

As Europe’s biggest military power along with France, Britain is central to European security efforts but London cannot continue to lead EU missions post-Brexit, EU and British negotiators agreed in March.

Madrid plans to run Atalanta from the Rota naval base in southern Spain, replacing the Northwood site outside London. France’s naval base at Brest will also be involved.

Italy had also sought command of Atalanta, which also protects food shipments to Somali refugees, and offered to run it alongside its command of the EU naval force in the Mediterranean.

The EU needs a formal decision by the end of June because moving the command will take 40 weeks and must be in place on March 30, 2019, the day after Britain leaves, according to an EU document seen by Reuters.

“We have reached a compromise,” an EU diplomat involved in the discussions told Reuters.

Two other diplomats and officials said Spain had offered Italy more naval support in combating migrant smuggling in the Mediterranean as part of the deal.

Rome has repeatedly complained that it is getting little help from other EU states in dealing with migrants crossing from Libya. Its new government refused earlier this month to let an aid ship carrying 629 migrants land in Italy, but Spain broke the deadlock by agreeing to let them disembark in Valencia.

Spain warned in a letter last November that China’s rising military presence in the Horn of Africa region meant that letting the Atalanta mission lapse after Britain left the EU was not an option.

By taking over the mission at Rota, Spain also hopes to cement its new status as one of the EU’s military “operational headquarters”, with French blessing. Britain, France, Germany, Italy and Greece currently host the other EU HQs.

EU defense ministers will also agree on Monday rules for a new military pact that excludes Britain.

France supports a bigger role for Spain in EU missions, while it wants London in a new French-led European “intervention force” to keep Britain close in military cooperation.

Negotiations with Britain on a new defense and security relationship began in May but have yet to advance.

Britain wants the closest possible defense and security ties with the EU, but the European Commission says it must be treated as a non-EU country without the same benefits and access to EU security databases and military procurement programs.