This study examines how a labor cost shock affects firms’ research and development (R&D) activity, focusing on the heterogeneous effect across firm size. Using the difference-in-differences approach, we investigate the R&D effect of Labor Contract Law (LCL) on firms in China. Empirical evidence reveals that, when considering the law binding issue, strict enforcement of the LCL has a negative treatment effect on treated firms’ R&D expenditure, which was reduced by 3.03%–6.75% on average, but it did not affect their likelihood of engaging in R&D. Crucially, the LCL’s R&D effect varies greatly by firm size. There is a positive treatment effect for large and medium-sized firms, whereas small treated firms reduce R&D in response to the labor cost shock. These heterogeneous effects apply to R&D propensity across firm size. The potential mechanisms for mitigating the LCL’s cost impact are discussed. Robustness checks reaffirm the above findings.