Aloja as a settlement was first mentioned in written sources in 1449. Aloja saw rapid development after Latvian agrarian reforms in 1920. In 1925 Aloja was granted a status of a village and it became also a centre of the parish. In 1936 new Rīga- Rūjiena railway line was constructed through Aloja. In 1992 Aloja was granted town rights. Since 2009 Aloja is administrative center of the Aloja municipality.