The UK had won the contract, in 2010, to provide the centre for EU's advanced GPS satellite system but the European Commission decided the centre must be relocated to remain in the EU once Britain leaves.
The Galileo system went live last year and will eventually involve 30 satellites but the new base for the Galileo Security Surveillance Centre will be fully operation from Madrid by April 2019.
“Today the committee of the member states' representatives met and we can confirm that the committee voted in favour, by a large majority, of our commission proposal to relocate the centre to Spain,” a spokesperson for the European commission told reporters in Brussels on Thursday.
The committee of 27 member states – excluding the UK - voted almost unanimously to move the Galileo satellite centre to Madrid, but the decision will not be made official until next week.
The centre will provide back up to the Galileo system, supporting the primary hub in Saint-Germain-en-Laye, near Paris.
The system is designed to provide highly accurate global positioning information for phones, cars, maritime, air, rail and emergency services and was created so the EU had its own technology, and would not be forced to rely on the system provided by the US military.
The Spanish government hopes the centre, which will cost about €4 million to build, will support up to 100 direct jobs.
It will be located in San Martín de la Vega, on an industrial estate 35km southwest of the capital.
Cristina Cifuentes, president of the Madrid regional government speaking ahead of the news that Spain's bid had been successful said “It would be great news , consolidating Madrid as a leader in technology.”
This is the third European agency confirmed to leave the UK as a result of Brexit.
The European Banking Authority (EBA) is due to move to Amsterdam in early 2019 and the European Medicines Agency (EMA) will transfer to Paris.