Spanish spies warned their Moroccan counterparts and the Madrid government of the Ceuta migrant surge a day before it happened.
A newly released note shows the National Intelligence Centre (CNI) informed Morocco's DGST and DGED of plans on social media involving swimming round the border or climbing the fence.
More than 70,000 people crossed into Spain's North African enclave the following day.
Spanish intelligence also tipped off their government's representative in Ceuta, according to declassified WhatsApp texts.
"There are two different groups with a total of 180,000 followers. Just to give you an idea of the scale," the CNI wrote, referencing the size of the social media groups.
Scenes of thousands swimming the short distance into Ceuta on rubber rings made headlines across the world. Charities estimate 140 died from drowning or being crushed in the stampede.
Of those that crossed the border, many left in the days that followed but an estimated 10,000 remain in makeshift camps and on streets and beaches. There are ongoing protests in Ceuta and on the mainland over the government's handling of the situation.
Smaller groups apparently preparing to cross into Ceuta from Morocco have been apprehended in recent weeks.
Morocco has not yet responded to the documents but Spain's foreign minister said there had been no warning of the scale of the 30 July influx.
"I was not aware of any information of any kind pointing to the magnitude of the avalanche," Jose Manuel Albares told reporters.
Prime Minister Pedro Sanchez said last week there was no evidence Moroccan authorities were behind the incident, contradicting claims in a police report.
However, the interior ministry has reported that Moroccan border police were passive on the day of the surge - a claim backed up by some of those who crossed.
Read more from Sky News:
AI 'could kill all humans'
LIV Golf files for bankruptcy
The spies' warning was revealed as part of 40 intelligence reports, alerts and communications that Mr Sanchez pledged to make public.
They show the situation building in the week before the mass crossing.
A defence ministry internal presentation - published the day it happened - warned of "migratory chaos" and said about 1,700 migrants had arrived and "more intrusions are to be expected in the very short-term."
(c) Sky News 2026: Spanish spies warned of mass migrant crossing into Ceuta the day before thousands breached b

More than 10% chance AI 'could kill all humans' - as Anthropic reveals another 'cybersecurity' incident
Man charged with assisting Russian intelligence
Tate brothers to stay in US jail, court rules, as they fight extradition to Britain





