(1) Background: The study aimed to analyze the influence of atrial fibrillation (AF) prior to hospital admission (“prevalent”) and new-onset AF diagnosed during hospital admission (“incident”) on in-hospital mortality (IHM) in women and men who developed hospital-acquired pneumonia (HAP) in Spain (2016–2019). (2) Methods: We used the Spanish Register of Specialized Care-Basic Minimum Database. (3) Results: We analyzed 38,814 cases of HAP (34.6% women; 13.5% ventilator-associated). Prevalent AF was coded in 19.9% (n = 7742), and incident AF in 5.5% (n = 2136) of HAP. Crude IHM was significantly higher for prevalent AF (34.22% vs. 27.35%, p < 0.001) and for incident AF (35.81% vs. 28.31%, p < 0.001) compared to no AF. After propensity score matching, IHM among women and men with prevalent AF was higher than among women and men with no AF (among women, 32.89% vs. 30.11%, p = 0.021; among men, 35.05% vs. 32.46%, p = 0.008). Similarly, IHM among women and men with incident AF was higher than among women and men with no AF (among women, 36.23% vs. 29.90%, p = 0.013; among men, 35.62% vs. 30.47%; p = 0.003). Sex was associated with a higher IHM only in people with incident AF (for female, OR = 1.21; 95% CI: 1.01–1.57). (4) Conclusions: Both prevalent and incident AF were associated with higher IHM in people who developed HAP. Female sex was associated with a higher IHM in incident AF.