We determined effective temperatures, surface gravities, and metallicities for a sample of 343 M dwarfs observed with CARMENES, the double-channel, high-resolution spectrograph installed at the 3.5 m telescope at Calar Alto Observatory. We employed SteParSyn, a Bayesian spectral synthesis implementation particularly designed to infer the stellar atmospheric parameters of late-type stars following a Markov chain Monte Carlo approach. We made use of the BT-Settl model atmospheres and the radiative transfer code turbospectrum to compute a grid of synthetic spectra around 75 magnetically insensitive Fe i and Ti i lines plus the TiO γ and bands. To avoid any potential degeneracy in the parameter space, we imposed Bayesian priors on T eff and log g based on the comprehensive, multi-band photometric data available for the sample. We find that this methodology is suitable down to M7.0 V, where refractory metals such as Ti are expected to condense in the stellar photospheres. The derived T eff , log g, and [Fe/H] range from 3000 to 4200 K, 4.5 to 5.3 dex, and −0.7 to 0.2 dex, respectively. Although our T eff scale is in good agreement with the literature, we report large discrepancies in the [Fe/H] scales, which might arise from the different methodologies and sets of lines considered. However, our [Fe/H] is in agreement with the metallicity distribution of FGK-type stars in the solar neighbourhood and correlates well with the kinematic membership of the targets in the Galactic populations. Lastly, excellent agreement in T eff is found for M dwarfs with interferometric angular diameter measurements, as well as in the [Fe/H] between the components in the wide physical FGK+M and M+M systems included in our sample.