We present near-infrared (1.15–2.50 μm) medium-resolution (R= 1700) spectroscopy of a sample of 23 brown dwarf candidates in the young Upper Sco association. We confirm membership of 21 brown dwarfs based on their spectral shape, comparison with field dwarfs and presence of weak gravity-sensitive features. Their spectral types range from M8 to L2 with an uncertainty of a subclass, suggesting effective temperatures between 2700 and 1800 K with an uncertainty up to 300 K and masses in the 30–8 MJup range. Among the non-members, we have uncovered a field L2 dwarf at a distance of 120–140 pc, assuming that it is single. The success rate of our photometric selection based on five photometric passbands and complemented partly by proper motion is over 90 per cent, a very promising result for future studies of the low-mass star and brown dwarf populations in young open clusters by the UKIDSS [UKIRT (United Kingdom Infrared Telescope) Infrared Deep Sky Survey] Galactic Cluster Survey. We observe a large dispersion in the magnitude versus spectral-type relation which is likely the result of the combination of several effects including age dispersion, extent and depth of the association, a high degree of multiplicity and the occurrence of discs.