We present the discovery of an 18.5±0.5MJup brown dwarf (BD) companion to the M0V star TOI-1278. The system was first identified through a percent-deep transit in TESS photometry; further analysis showed it to be a grazing transit of a Jupiter-sized object. Radial velocity (RV) follow-up with the SPIRou near-infrared high-resolution velocimeter and spectropolarimeter in the framework of the 300-night SPIRou Legacy Survey (SLS) carried out at the Canada-France-Hawaii Telescope (CFHT) led to the detection of a Keplerian RV signal with a semi-amplitude of 2306±10 m/s in phase with the 14.5-day transit period, having a slight but non-zero eccentricity. The intermediate-mass ratio (M⋆/Mcomp∼31) is unique for having such a short separation (0.095±0.001 AU) among known M-dwarf systems. Interestingly, M dwarf-brown dwarf systems with similar mass ratios exist with separations of tens to thousands of AUs.