Very fun question! I've mentioned Alcácer Quibir probably dozens of times in explaining the relations between Portuguese and Spanish and the Iberian Union, and it's really refreshing to try and look at it from the North African persepctive.
So, first to give some context, Morocco in the 16th century was in a unfavorable position. Portuguese held many of the coastal towns and together with Spanish dominated the seas around it. The Ottomans were at the same time increasing their presence in North African affairs, and after creating some form of dominion over Algiers and Tunisia, they tried to do the same to Morocco (which especially worried the Iberians as they were afraid of Ottomans having Atlantic ports). Internally Morocco was very divided. Most of the people were organized into larger tribal organizations, and to be in power you had to juggle all those which was very difficult if not impossible. Further on, geographically Morocco can easily be divided into Southern part, centered around Marrakesh (back then sometimes referred to as just Morocco) and Northern part with the capital of Fez. Civil wars were usual where parties controlling one center were trying to conquer the other. Iberian powers and Ottomans were leveraging this weakness and constantly trying to bring Morocco more under their influence
One of such civil wars brought about Alcácer Quibir. As we know, in it Portuguese king Sebastian was aiding the ousted Abu Abdallah Mohammed II against his uncle Abd Al-Malik I backed by Ottomans. The Portuguese army was completely destroyed, and all of the three above mentioned men died, making al-Malik's brother Ahmad al-Mansur new Sultan. This was probably the most important consequence of the battle as al-Mansur was a very influential ruler whose actions had large consequences for the region. With the reputaton of being the winner of such a grand battle, Ahmad al-Mansur went on to solidify his rule of Morocco and to resist the Iberians and the Ottomans, his previous backers.
To do so he relied on one of the major consequences of the battle of Alcácer Quibir. After the defeat many Europeans, mostly but not exclusively Portuguese, remained imprisoned in Morocco. While some were ransomed back, many were not that lucky and stayed captives. A way out of this captivity was to convert to islam and become a Renagade, and many did exactly this. Al-Mansur was quick to see the potential of men with experience in modern gunpowder weapons, and hired many of those renegades in his personal army, creating a corps of modern soldiers loyal only to him, helping him solidify his hold on Morocco. With time most of this corps would be filled and dominated by Morisco refugees from Spain, but in this early phase the initial men were prisoners from Alcácer Quibir. Similarly, the men of Alcácer Quibir with Moriscos and Jews fleeing from Iberian peninsula formed the basis for al-Mansur's mini modernization program, creating sugar mills, mines, irrigation systems and gunpowder weapon production centers.
Encouraged with these developments, al-Mansur's foreign policy led to Morocco's highly independent status. Spanish king Phillip II, already refusing to send troops with Sebastian, was even less willing to intervene directly military, and had resorted to dealing with al-Mansur by other means and political intrigues. Al-Mansur also moved away from the Ottomans pitting them against the Spanish and playing them against each other to his benefit. Probably most relevant was the started diplomacy between Morocco and Queen Elizabeth of England in the 1590s. England, at war with Spanish, approached Morocco and started diplomatic and trade relations, often selling weapons and military supplies, a previous no-no. Queen Elizabeth attempted to enlist Morocco to join the English invasion of Portugal to place their own claimant to Portuguese throne Dom Antonio, instead of Spanish king Phillip II who then jointly ruled Portugal and Spain (as a consequence of king Sebastian dying in the battle without an heir). Al-Mansur was full of promises, but once he got hostages he wanted (Dom Antonio's son) he dropped all pretenses of joining the invasion, and tried to get Phillip to give up some of his claimants to Morocco's throne he harbored in exchange for the Portuguese claimants. This backfired after England attempted the invasion anyway, which failed completely by the way, and then Phillip sent his Moroccan claimants to Morocco to start the rebellion and who, without any real Spanish material support, managed to create a large uprising which al-Mansur's son barely managed to defeat (and then in turn the son rebelled against his father al-Mansur, but was defeated)
While not joining the invasion of Iberia, al-Mansur was not idle with his new built military prowess. He used his new core and weapons from his new manufactures and one traded from England and in 1590 launched an invasion of Songhai Empire trying to capture the gold mines there. His army was consisted of his firearm Renegade/Morisco corps and classic Moroccan cavalry from loyal tribes and did manage to conquer Timbuktu, Djenne and capital of Gao. The control didn't last though, and by 1620s the area was free from Moroccan control. The same goes for majority of Morocco. While al-Mansur managed to control both halves, after his death his sons, each in respective domain, lead civil war against each other. Still the changes made, especially the influx of Renegades and Moriscos remained, creating a new layer of Moroccan society, most famously embodied in the Barbary pirates who in Morocco created the famous Sale republic.