Please help! I’m an Australian citizen. I came to Spain and have applied for the NIE. I'm still waiting for the decision from the immigration office. My 90-day stay expires before I get my NIE approved, and as far as I understand, it will be no problem to stay in Spain even after the 90 days expired. But what happens after I get my NIE? I will need to go to Portugal and I’m worried that the 90-day limit in the Schengen zone will be no longer available. Do I need to apply for a visa to go to Portugal, or am I allowed to travel around the EU with my Spanish NIE?
The NIE isn't particularly helpful; it's just a number. It's the card that you are really concerned about. I realize people call it an NIE but it is actually a permiso de residencia, a residence permit.
That card allows you to travel to other Schengen countries for up to 90 days in any 180-day period, and you are correct to be concerned, because your 90-day visa free stay in Spain should technically be considered in calculating whether you can go to Portugal.
However, there is no systematic enforcement of the 90-day limit for people who hold a residence card or long-term visa. There are no systematic border controls between Spain and Portugal. Nobody will record the fact that you traveled to Portugal. Depending on how you travel, it is very likely that nobody will even look at your passport or residence permit.
If you get in trouble with the Portuguese police and they figure out that you're not technically supposed to be there, they could perhaps deport you, but the chance of their figuring out that you've technically overstayed is pretty small. They would have to see that you entered the Schengen area more than 90 days before your current residence permit was issued, and that you didn't have another permit or long-stay visa during that time. I will leave it to you to judge the chance of your getting in trouble with the police in the first place, but for most people it is very low indeed.
Even in the extremely unlikely event that you did get "found out," the fact that you were staying in Spain legally while awaiting the issue of your residence permit would probably save you from trouble. The point of the law is to prevent people from abusing the residence permit system by living in a country while having a permit from a different country. If you're not trying to do that, you're unlikely to have problems even if the law isn't precise enough to allow you to do what you're doing.
Finally, if you go to Portugal more than 90 days after receiving your residence permit, you are technically in the clear. For example, if you go on the 91st day, you have to count that day for your 90/180 calculation, but you exclude the preceding 90 days, because you had the residence card. Then you count the preceding 89 days, to fill out the 180-day period, and arrive at a total of 90 days in 180, making your presence in Portugal completely legal.