Aims. We report on radial velocity time series for two M0.0 V stars, GJ 338 B and GJ 338 A, using the CARMENES spectrograph, complemented by ground-telescope photometry from Las Cumbres and Sierra Nevada observatories. We aim to explore the presence of small planets in tight orbits using the spectroscopic radial velocity technique. Methods. We obtained 159 and 70 radial velocity measurements of GJ 338 B and A, respectively, with the CARMENES visible channel between 2016 January and 2018 October. We also compiled additional relative radial velocity measurements from the literature and a collection of astrometric data that cover 200 a of observations to solve for the binary orbit. Results. We found dynamical masses of 0.64 ± 0.07 M for GJ 338 B and 0.69 ± 0.07 M for GJ 338 A. The CARMENES radial velocity periodograms show significant peaks at 16.61 ± 0.04 d (GJ 338 B) and 16.3 +3.5 −1.3 d (GJ 338 A), which have counterparts at the same frequencies in CARMENES activity indicators and photometric light curves. We attribute these to stellar rotation. GJ 338 B shows two additional, significant signals at 8.27 ± 0.01 and 24.45 ± 0.02 d, with no obvious counterparts in the stellar activity indices. The former is likely the first harmonic of the star's rotation, while we ascribe the latter to the existence of a super-Earth planet with a minimum mass of 10.27 +1.47 −1.38 M ⊕ orbiting GJ 338 B. We have not detected signals of likely planetary origin around GJ 338 A. Conclusions. GJ 338 Bb lies inside the inner boundary of the habitable zone around its parent star. It is one of the least massive planets ever found around any member of stellar binaries. The masses, spectral types, brightnesses, and even the rotational periods are very similar for both stars, which are likely coeval and formed from the same molecular cloud, yet they differ in the architecture of their planetary systems.