Article 156.5 of the Notarial Regulation, in its current wording that is determined by RD 1804/2008 of November 3, includes as a requirement of public deeds, related to acts or contracts by which they are acquired, declared, constituted, transmitted, encumber, modify or extinguish the domain and other real rights over real estate, or to any others with tax significance, that the tax identification number of those appearing, that is, of those who are in the presence of the Notary to sign the document, as well as of the persons or entities on whose behalf they act, must be recorded.
The lack of presentation of this tax identification number does not prevent the granting of the deed, although it will close the Property Registry in the event that the deed is registrable, and in any case the Notary must give the appropriate warning.
A tax identification number is held by all persons of Spanish nationality, as it coincides with the number on their identity document and also by persons who have their residence in Spain, as it will coincide with the number on their residence card.
Non-resident persons or entities in Spain who intend to carry out any act of a tax nature must request a foreign identification number, the procedure for obtaining which is regulated in RD 557/2011, which approves the Regulations of the Law Organic 4/2000, on the rights and freedoms of foreigners, specifically in its article 206 that says:
The personal number will be the identifier of the foreigner, which must appear in all the documents that are issued or processed, as well as in the proceedings that are stamped in their passport or similar document, except for visas.
The identity number of the foreigner, NIE, must be granted ex officio, by the General Directorate of the Police and the Civil Guard, in the cases mentioned in section 1, except in the case of foreigners who are related to Spain for reason of their economic, professional or social interests, which should be of interest to said body in assigning the indicated number, provided that the following requirements are met:
a) That they are not in Spain in an irregular situation.
b) That the reasons for requesting the assignment of said number be communicated.
Foreigners who have a relationship with Spain due to their economic, professional or social interests may personally request the NIE from the General Directorate of the Police and the Civil Guard, directly or through the Immigration Offices or Police Stations. In the event that the foreigner is not in Spanish territory at the time of the application, they will request the assignment of a NIE to the General Commissariat for Immigration and Borders, through the Consular Offices of Spain abroad.
The procedure must be resolved within a maximum period of five days from the entry of the application in the register of the competent body for its processing.
The application form to be filled out is EX15, which can be download here.
Despite the fact that according to the letter of the law, only personal applications are admitted, the interpretation that has been made of the precept admits the application of the NIE in Spain through a representative authorized to do so with power of attorney (Ministry of Interior).
It is worth highlighting the following link regarding immigration procedures. And finally that the offices of the national police in the city of Lleida, where you can carry out all the procedures described, are located at number 15 Jaume II street.