Microbial mats are often found in intertidal areas experiencing a large range of salinities. This study investigated the effect of changing salinities on nitrogenase activity and on the composition of the active diazotrophic community (nifH transcript libraries) of three types of microbial mats situated along a littoral gradient. All three mat types exhibited highest nitrogenase activity at salinities close to ambient seawater or lower. The response to lower or higher salinity was strongest in mats higher up in the littoral zone. Changes in nitrogenase activity as the result of exposure to different salinities were accompanied by changes in the active diazotrophic community. The two stations higher up in the littoral zone showed nifH expression by Cyanobacteria (Oscillatoriales and Chroococcales) and Proteobacteria (Gammaproteobacteria and Deltaproteobacteria). At these stations, a decrease in the relative contribution of Cyanobacteria to the nifH transcript libraries was observed at increasing salinity coinciding with a decrease in nitrogenase activity. The station at the low water mark showed low cyanobacterial contribution to nifH transcript libraries at all salinities but an increase in deltaproteobacterial nifH transcripts under hypersaline conditions. In conclusion, increased salinities caused decreased nitrogenase activity and were accompanied by a lower proportion of cyanobacterial nifH transcripts.