The Verdict: Need More Info
Time without a permit does not count towards nationality, but it can qualify you for a permit through arraigo. Regularise first; your nationality clock starts the day your permit begins.
Since the 2025 regulation, arraigo needs two years in Spain rather than three, with versions based on work, social ties, family, or training for an occupation in short supply.
Your time in Spain is the evidence for arraigo, so keep anything that proves it, such as padrón registration, medical records and rental contracts.
Which version fits depends on your work, family and documents, so take advice. After that, the wait for nationality is two years for nationals of origin of Latin American countries, Andorra, Portugal, the Philippines and Equatorial Guinea, and ten for everyone else.