Event-by-event fluctuations of the mean transverse momentum of charged particles produced in pp collisions at 0.9, 2.76 and 7 TeV, and Pb–Pb collisions at 2.76 TeV are studied as a function of the charged-particle multiplicity using the ALICE detector at the LHC. Dynamical fluctuations indicative of correlated particle emission are observed in all systems. The results in pp collisions show little dependence on collision energy. The Monte Carlo event generators PYTHIA and PHOJET are in qualitative agreement with the data. Peripheral Pb–Pb data exhibit a similar multiplicity dependence as that observed in pp. In central Pb–Pb, the results deviate from this trend, featuring a significant reduction of the fluctuation strength. The results in Pb–Pb are in qualitative agreement with previous measurements in Au–Au at lower collision energies and with expectations from models that incorporate collective phenomena.