The SARS-CoV-2 main protease (M<sup>pro</sup>) is a medicinal chemistry target for COVID-19 treatment. Given the clinical efficacy of β-lactams as inhibitors of bacterial nucleophilic enzymes, they are of interest as inhibitors of viral nucleophilic serine and cysteine proteases. We describe the synthesis of penicillin derivatives which are potent M<sup>pro</sup> inhibitors and investigate their mechanism of inhibition using mass spectrometric and crystallographic analyses. The results suggest that β-lactams have considerable potential as M<sup>pro</sup> inhibitors via a mechanism involving reaction with the nucleophilic cysteine to form a stable acyl-enzyme complex as shown by crystallographic analysis. The results highlight the potential for inhibition of viral proteases employing nucleophilic catalysis by β-lactams and related acylating agents.