The bioavailability of nutrients is important in controlling ecological processes and nitrogen cycling in oligotrophic mangrove forests, yet the variation of diazotrophic community structure and activity with nutrient availability in sediments remains largely unexplored. To investigate for the first time how nutrients in sediments affect spatial and temporal patterns of diazotrophic community structure and activity, the sedimentary environment of Twin Cays, Belize, was examined with respect to the effects of long-term fertilization [treatments: control (Ctrl), nitrogen (N), and phosphorus (P)] on N2 fixation rates and nifH gene community structure. We found that N2 fixation rates were significantly higher at the P-treatment, intermediate at the Ctrl-treatment and lower in the N-treatment (P: 4.2 ± 0.5, Crtl: 0.8 ± 0.1, N: 0.4 ± 0.1 nmol·N·g−1·h−1; P < 0.001) with spatial (Ctrl- and P-treatments) and temporal (only P-treatment) variability positively correlated with live root abundance (r2 = 0.473, P < 0.001) and concentration (r2 = 0.458, P < 0.0001). The community structure of diazotrophs showed larger spatial and temporal variability in the fertilized treatments than in the Ctrl-treatment, with the relative abundance of OTUs (nifH operational taxonomic units) at the fertilized treatments inversely related to live root abundance. Overall, long-term fertilization (with either N or P) affects not only nutrient levels in mangrove sediments directly, but also spatial and temporal patterns of both community structure and activity and likely plant-microbe interactions as well. Our findings suggest that the maintenance of natural nutrient conditions in mangrove sediments is important to ensure the stability of microbial functional groups like diazotrophs.