We present the first measurement of the gravitational quadrupole moment of the companion star of a spider pulsar, namely the black widow PSR J2051−0827. To this end we have re-analysed radio timing data using a new model which is able to account for periastron precession caused by tidal and centrifugal deformations of the star as well as by general relativity. The model allows for a time-varying component of the quadrupole moment, thus self-consistently accounting for the ill-understood orbital period variations observed in these systems. Our analysis results in the first detection of orbital precession in a spider system at ω˙=−68.6−0.5+0.9 deg/yr and the most accurate determination of orbital eccentricity for PSR J2051−0827 with e=(4.2±0.1)×10−5. We show that the variable quadrupole component is about 100 times smaller than the average quadrupole moment Qˉ=−2.2−1+0.6×1041 kg.m2. We discuss how accurate modelling of high precision optical light curves of the companion star will allow its apsidal motion constant to be derived from our results.