We study the M1.9-class solar flare SOL2015-09-27T10:40 UT using high-resolution full Stokes imaging spectropolarimetry of the Ca ii 8542 Å line obtained with the CRISP imaging spectropolarimeter at the Swedish 1-m Solar Telescope. Spectropolarimetric inversions using the non-LTE code NICOLE are used to construct semiempirical models of the flaring atmosphere to investigate the structure and evolution of the flare temperature and magnetic field. A comparison of the temperature stratification in flaring and nonflaring areas reveals strong heating of the flare ribbon during the flare peak. The polarization signals of the ribbon in the chromosphere during the flare maximum become stronger when compared to its surroundings and to pre- and post-flare profiles. Furthermore, a comparison of the response functions to perturbations in the line-of-sight magnetic field and temperature in flaring and nonflaring atmospheres shows that during the flare, the Ca ii 8542 Å line is more sensitive to the lower atmosphere where the magnetic field is expected to be stronger. The chromospheric magnetic field was also determined with the weak-field approximation, which led to results similar to those obtained with the NICOLE inversions.