This study examines the impact of having a credit rating on earnings management (EM) through accruals and real activities manipulation by initial public offering (IPO) firms. We find that firms going public with a credit rating are less likely to engage in income-enhancing accrual-based and real EM in the offering year. The monitoring by a credit rating agency (CRA) and the reduced information asymmetry due to the provision of a credit rating disincentivise rated issuers from managing earnings. We also suggest that the participation of a reputable auditing firm is crucial for CRAs to effectively restrain EM. Moreover, we document that for unrated issuers, at-issue income-increasing EM is not linked to future earnings and is negatively related to post-issue long-run stock performance. However, for rated issuers, at-issue income-increasing EM is positively associated with subsequent accounting performance and is unrelated to long-run stock performance following the offering. The evidence indicates that managers in unrated firms generally manipulate earnings to mislead investors, while managers in rated firms tend to exercise their accounting and operating discretion for informative purposes.