The housekeeping sortase A (SrtA), a membrane-associated cysteine transpeptidase, is responsible for anchoring surface proteins to the cell wall peptidoglycan in Gram-positive bacteria. This process is essential for the regulation of bacterial virulence and pathogenicity. Therefore, SrtA is considered to be an ideal target for antivirulence therapy. In this study, we report that ML346, a compound with a barbituric acid and cinnamaldehyde scaffold, functions as an irreversible inhibitor of Staphylococcus aureus SrtA (SaSrtA) and Streptococcus pyogenes SrtA (SpSrtA) in vitro at low micromolar concentrations. According to our X-ray crystal structure of the SpSrtAΔN81/ML346 complex (Protein Data Bank ID: 7V6K), ML346 covalently modifies the thiol group of Cys208 in the active site of SpSrtA. Importantly, ML346 significantly attenuated the virulence phenotypes of S. aureus and exhibited inhibitory effects on Galleria mellonella larva infection caused by S. aureus. Collectively, our results indicate that ML346 has potential for development as a covalent antivirulence agent for treating S. aureus infections, including methicillin-resistant S. aureus.