Self-promotion in science is ubiquitous but not exercised to the same extent by everyone. It is unclear whether there are gender differences in the frequency of self-promotion or the benefits individuals get from it. Here, we examine gender differences in scholarly self-promotion using 7M Tweet mentions of 539K research papers published in 2018 by 1.3M authors. Our analysis shows that female authors are significantly less likely than male authors to promote their papers, even after controlling for a number of important factors including journal impact, affiliation prestige, author productivity and number of citations, authorship position, number of coauthors, and research topics. The magnitude of the gender gap is more strongly associated with papers' journal impact factor than authors' affiliation prestige, previous productivity, or academic discipline. In particular, male scholars are 60% more likely than comparable female scholars to self-promote papers published in journals with very high impact factor, whereas the difference is only 28% for papers in low impact journals. Although women self-promote less often overall, when they do, their papers receive slightly more mentions on Twitter. Our findings offer the first large-scale evidence for a gender gap in scholarly self-promotion online and show the circumstances under which the gap is most substantial, helping inform policy aimed at mitigating discrepancies in visibility and recognition.