The trove of 40 documents, which includes alerts, intelligence reports, charts and communications from multiple law enforcement and intelligence agencies, appears to undermine what Spanish Prime Minister Pedro Sánchez has said about the level of prior warning the government had before the sudden influx took place.
Major protests in Spain have taken place in response to the migrant arrivals, with critics blaming the Sánchez government for its handling of the crisis, and his political opponents accusing him of pandering to Morocco.
On July 29, a day before more than 72,000 people began pouring into the Spanish city neighbouring Morocco, Spain's spy agency, the National Intelligence Center (CNI), sent an alert via WhatsApp to the Spanish government's delegation in Ceuta about calls on social media "for an assault on the fence and by sea tomorrow at 8 pm"
"There are two different groups with a total of 180,000 followers," the declassified WhatsApp message from the intelligence agency said, "just to give you an idea of its scale."
A note by Spain's spy agency that day to Moroccan intelligence agencies warned of plans on social media for migrants to enter Ceuta on July 30 by climbing a border fence separating the exclave from Morocco, or by swimming around it, the documents show. It mentioned that migrants might take advantage of Morocco's national Throne Day, celebrated on July 30.
That same day, Spain's national intelligence agency issued similar warnings about "several groups on Facebook and WhatsApp encouraging these attempts" in messages to Spain's Civil Guard police force.
Morocco's foreign ministry did not immediately respond to a request for comment from The Associated Press on Wednesday about the report.
On Wednesday, Sánchez rejected the idea the declassified documents revealed there was prior warning about a mass crossing of the scale that took place between July 30 and 31.
"The existence of this campaign was known ... and was being monitored, but in no way did it constitute or could it be interpreted as an indicator of the scale, nature, or probability of what happened afterward," Sánchez wrote on X, referencing the spy agency's July 29 warning about what was brewing on social media.
Sánchez has defended his government's handling of the crisis and said last week there was no evidence that Morocco's government orchestrated the incident. That sparked further criticism, particularly after a leaked police report alleged the involvement of Moroccan police in the episode.
Several weeks after the initial border rush, Ceuta is dealing with a prolonged humanitarian crisis because of some 5000 migrants who remain in the small city, according to the national government. Local officials cite a higher figure of up to 10,000.
The Spanish leader last week pledged to release documents related to Spain's deadliest mass crossing, in which NGOs reported more than 140 migrants died.
Wednesday's document trove includes reports from multiple agencies that detailed the rising arrivals, a surge that overwhelmed authorities beginning July 30.