Strong gravitational lensing magnifies the flux from distant galaxies, allowing us to detect emission lines that would otherwise fall below the detection threshold for medium-resolution spectroscopy. Here we present the detection of temperature-sensitive oxygen emission lines from three galaxies at 2 ≲ z ≲ 3.5, which enables us to directly determine the oxygen abundances and thereby double the number of galaxies at z > 2 for which this has been possible. The three galaxies have ∼10 per cent solar oxygen abundances in agreement with strong emission-line diagnostics. Carbon and nitrogen ratios relative to oxygen are subsolar as expected for young metal-poor galaxies. Two of the galaxies are Lyman α (Lyα) emitters with rest-frame equivalent widths of 20 and 40 Å, respectively, and their high magnification factors allow us for the first time to gain insight into the physical characteristics of high-redshift Lyα emitters. Using constraints from the physical properties of the galaxies, we accurately reproduce their line profiles with radiative transfer models. The models show a relatively small outflow in agreement with the observed small velocity offsets between nebular emission and interstellar absorption lines.