Statistics agency INE insists the eight-day project is anonymous and aimed at getting a better idea of where Spaniards go during the day and night.
The three biggest mobile companies are taking part in the scheme.
They say that by handing over the data they are not breaking any laws.
What is the idea of tracking mobiles?
The statistics agency wants to track the movement of Spaniards over eight days, first to their places of work or study from 18-21 November and later on days off and holidays. The second part of the experiment will be done on Sunday 24 November, Christmas Day and two days next summer.
The three companies - Movistar, Vodafone and Orange - cover 78.7% of Spain's mobile phone users and are to be paid a total of €500,000 (£430,000; $550,000) for taking part in the study.
The country will be divided up into 3,200 cells with more than 5,000 residents, and the operators will work out how many phones are within each cell at various times of day. They will analyse phones between midnight and 06:00 to find out where people live and then later between 09:00 and 18:00.
"We will know for example how many mobiles there are at 17:00 on a particular street in any city of more than 15,000 people, but no more than that," INE told the El Confidencial website.
Once all the data is analysed, the agency hopes to have a clearer idea of when and where Spaniards travel and then use the information to improve transport and public services. INE wants to use the details in the next census in 2021.
The mobile operators insist there is no way users can be identified as no personal data is being transferred.
More about: Spain