Diaz was included in Walid Regragui's 24-man roster for the matches against Angola and Mauritania this month, according to a statement released by Morocco’s Football Federation.
The 24-year-old Los Blancos winger represented Spain in one game and scored against Lithuania in 2021.
FIFA rules say players can switch international allegiance when they have made fewer than three appearances for a country before the age of 21. They should also not have played for that nation for at least three years.
Diaz, a former AC Milan winger, has produced fine displays for Real Madrid this season, having scored eight goals in 32 games across all competitions.