Moroccans came far ahead of Bolivians (8157 people) Ecuadorians (7996 people) and Colombians (6846 people), the statistics institute said in a statement.
The number of Moroccans living legally in Spain rose to 812,412 by January 2019, 5.4% up compared to a year earlier, it said.
The Spanish nationality was given in total to 90,828 people last year, that is a 36.6% increase compared with a year earlier, the institute said, noting that 47.1% of the new Spanish citizens are men.
The summer period is usually marked by a rise in port traffic as many Moroccans living in Spain come back home for holidays.
With only 14km separating Morocco and Spain, millions cross the Strait to see their family members in Morocco. Moroccan authorities have taken special measures to facilitate the flow in an operation dubbed Marhaba.