People who have an economic or professional relation with Spain and those who have a social interest in it may apply for an N.I.E at the Directorate-General of the Police, either directly or through the Spain’s Consular Posts located abroad.

Those foreigners interested on applying for an N.I.E must submit an application form at the Consular Post of the area in which they are actually living, either personally or through an authorized representative, and the application form must be accompanied by a copy of the biographical page of the passport. The application form can be found here.

Source: Spanish Ministry of Foreign Affairs and Cooperation 

en