  The circumstellar disk of the Herbig Fe star HD 142527 is host to several
remarkable features including a warped inner disk, a 120 au-wide annular gap, a
prominent dust trap and several spiral arms. A low-mass companion, HD 142527 B,
was also found orbiting the primary star at $\sim$14 au. This study aims to
better characterize this companion, which could help explain its impact on the
peculiar geometry of the disk. We observed the source with VLT/SINFONI in
$H$+$K$ band in pupil-tracking mode. Data were post-processed with several
algorithms based on angular differential imaging (ADI). HD 142527 B is
conspicuously re-detected in most spectral channels, which enables us to
extract the first medium-resolution spectrum of a low-mass companion within
0.1'' from its central star. Fitting our spectrum with both template and
synthetic spectra suggests that the companion is a young M2.5$\pm$1.0 star with
an effective temperature of $3500\pm100$ K, possibly surrounded with a hot
(1700 K) circum-secondary environment. Pre-main sequence evolutionary tracks
provide a mass estimate of $0.34\pm0.06 M_{\odot}$, independent of the presence
of a hot environment. However, the estimated stellar radius and age do depend
on that assumption; we find a radius of $1.37 \pm 0.05 R_{\odot}$ (resp. $1.96
\pm 0.10 R_{\odot}$) and an age of $1.8^{+1.2}_{-0.5}$ Myr (resp. $0.75 \pm
0.25$ Myr) in the case of the presence (resp. absence) of a hot environment
contributing in $H$+$K$. Our new values for the mass and radius yield a mass
accretion rate of $\sim$5 $\times 10^{-9} M_{\odot}$ yr$^{-1}$ (2-3% that of
the primary). Our results illustrate thus the potential for SINFONI+ADI to
characterize faint close-in companions. The new spectral type makes HD 142527 B
a twin of the well known TW Hya T-Tauri star, and the revision of its mass to
higher values further supports its role in shaping the disk.
