Evidence about the relation between earnings management and voluntary audits is scarce, and there is no research about the effectiveness of mandatory audits to improve earnings quality. Using a sample of Spanish SMEs, where some companies are mandatorily audited and some are exempt from audit, we examine if audits, either mandatory or voluntary, help to improve accounting quality by constraining earnings management. We also examine differences between voluntary and mandatory audits, as well as the role of Big 4 and Middle-Tier auditors. After controlling for other characteristics that affect earnings management, we find that audited companies have lower absolute discretionary accruals, but do not find significant differences among auditors. Voluntary audits also restrain earnings management, but in a lesser extent than mandatory audits. When we use signed accruals, audits are only effective against income-increasing behaviours, what is explained by the auditor conservatism. Additional analyses support the results obtained.