Background Aspirin and other non-steroidal anti-inflammatory drugs (NSAIDs) may have a preventive effect against prostate cancer. However, evidence is limited and still controversial, especially considering non-aspirin non-steroidal antiinflammatory drugs (NSAIDs). Methods Swedish nationwide population-based cohort study including all long-term (≥180 days) adult male users of aspirin (n = 419,931) or NSAIDs (n = 223,437) followed from the first dispense date until the first cancer diagnosis, death or 31 December 2012, whichever occurred first. The risk of prostate cancer was measured as standardized incidence ratios (SIR) and 95% confidence intervals (CI), assessing duration of use, age and concomitant statins intake, comparing to the general male background population of the same age in Sweden.Results The overall SIR suggests that maintenance use of aspirin decreases the risk of prostate cancer (SIR = 0.87, 95% CI 0.85-0.88), in particular if used ≥5 years (SIR = 0.31, 95% CI 0.30-0.32). The overall risk was decreased (SIR = 0.87, 95% CI 0.85-0.90) among other NSAIDs users, and again in particular among longer-term users (≥3 years) with SIR = 0.58 (95% CI 0.53-0.63). When statins users were excluded from all aspirin users, there was no remaining association with prostate cancer (SIR = 0.99, 95% CI 0.96-1.02), only if taken ≥5 years (SIR = 0.31, 95% CI 0.29-0.34). For non-aspirin NSAIDs users, the protective effect remained after exclusion of statins users (SIR = 0.92, 95% CI 0.88-0.95). Conclusions This population-based cohort study provides evidence for a protective effect of aspirin and other NSAIDs against prostate cancer, in particular for longer durations of use, yet concomitant use of statins strongly influences the risk among aspirin users.