Heart failure (HF) is a clinical syndrome caused by impairment of ventricular filling, ejection of blood, or both and is categorized as HF with reduced ejection fraction (HFrEF) or HF with preserved ejection fraction (HFpEF) based on left ventricular function. Cardiac fibrosis contributes to left ventricular dysfunction and leads to the development of HF. Ivabradine, an If current selective specific inhibitor, has been shown to improve the prognosis of patients with HF. However, the effects of ivabradine on cardiac function and fibrosis in HFpEF and HFrEF and the underlying mechanism remain unclear. In the present study, we utilized mouse models to mimic HFpEF and HFrEF and evaluated the therapeutic effects of ivabradine. By treating mice with different doses (10 mg/kg/d and 20 mg/kg/d) of ivabradine for 4 or 8 weeks, we found that a high dose of ivabradine improved cardiac diastolic function in HFpEF mice and ameliorated cardiac diastolic and systolic function and ventricular tachycardia incidence in HFrEF mice. Moreover, ivabradine significantly reduced the activation of cardiac fibroblasts and myocardial fibrosis in mice. Mechanistically, microRNA-133a, which was upregulated by ivabradine, targeted connective tissue growth factor and collagen 1 in cardiac fibroblasts and might contribute to the protective role of ivabradine. Together, our work utilized mouse models to study HFpEF and HFrEF, demonstrated the protective role of ivabradine in HFpEF and HFrEF, and elucidated the potential underlying mechanism, which provides an effective strategy for related diseases.