The legal procedure to get your visa in Spain is really simple.
After analyzing your situation and defining which is the best permit for you, the first step will be to go the consulate or embassy of Spain located at your country of origin, and submit the required documentation.
Be careful! Just those permits under the Entrepreneur Law (as well as the student visa) allow you to start the application process as a tourist in Spain. For all the other cases, you cannot be inside the country.
After submitting the required visa application form and all the other relevant documents, your file will be processed. After 3-4 months, you will receive a positive response, hence being able to travel to Spain and get your residence permit for one year. In this step, having your NIE number will be required.