Irregular mass migration is among the "hybrid threats" that hostile powers can use to undermine the stability of NATO countries, the alliance said in its new Strategic Concept agreed at a summit in Madrid on Wednesday.
Including such threats was an explicit request made by alliance countries on NATO's outer rims, including the summit's host Spain, which have seen neighbours use migration as a weapon of political pressure.
Poland's border crisis with Belarus last year was another example.
The Strategic Concept twice mentions migration as an element to monitor in the next decade and points to the southern flank as a new source of risk to stability.
"Conflict, fragility and instability in Africa and the Middle East directly affect our security and the security of our partners," the document said.
The allies agreed that areas to the south of NATO, particularly the Middle East, North Africa and Sahel regions, faced interconnected security, demographic, economic and political challenges spurred on by external powers.
"This situation provides fertile ground for the proliferation of non-state armed groups, including terrorist organisations. It also enables destabilising and coercive interference by strategic competitors."
At least 23 migrants died and many more were injured in the attempted mass crossing on Friday into the Spanish enclave of Melilla that borders Morocco.
The tragedy gave rise to debate on whether Article 5 of the NATO treaty applies to the defence of Melilla and the other Spanish enclave of Ceuta as they are located outside the boundaries that NATO considers its territory.
The wording of the new Strategic Concept removes any doubt, according to a senior Spanish government source, by explicitly including Spain's southern enclaves.
"No one should doubt our strength and resolve to defend every inch of allied territory, preserve the sovereignty and territorial integrity of all allies and prevail against any aggressor," the text said.
Separately, as part of measures to address challenges identified in the Sahel, NATO approved a defence capacity-building package for Mauritania.
Mauritania, which shares a border with troubled Mali, will receive support in "intelligence, special operations and maritime security" to address security concerns including irregular migration and border security, NATO Secretary-General Jens Stoltenberg told a briefing.