Atrial fibrillation (AF), the most common persistent clinical tachyarrhythmia, is associated with altered gene transcription which underlies cardiomyocyte dysfunction, AF susceptibility and progression. Recent research showed class I and class IIa histone deacetylases (HDACs) to regulate pathological and fetal gene expression, and thereby induce hypertrophy and cardiac contractile dysfunction. Whether class I and class IIa HDACs are involved in AF promotion is unknown. We aim to elucidate the role of class I and class IIa HDACs in tachypacing-induced contractile dysfunction in experimental model systems for AF and clinical AF. Methods and results: Class I and IIa HDACs were overexpressed in HL-1 cardiomyocytes followed by calcium transient (CaT) measurements. Overexpression of class I HDACs, HDAC1 or HDAC3, significantly reduced CaT amplitude in control normal-paced (1 Hz) cardiomyocytes, which was further reduced by tachypacing (5 Hz) in HDAC3 overexpressing cardiomyocytes. HDAC3 inhibition by shRNA or by the specific inhibitor, RGFP966, prevented contractile dysfunction in both tachypaced HL-1 cardiomyocytes and Drosophila prepupae. Conversely, overexpression of class IIa HDACs (HDAC4, HDAC5, HDAC7 or HDAC9) did not affect CaT in controls, with HDAC5 and HDAC7 overexpression even protecting against tachypacing-induced CaT loss. Notably, the protective effect of HDAC5 and HDAC7 was abolished in cardiomyocytes overexpressing a dominant negative HDAC5 or HDAC7 mutant, bearing a mutation in the binding domain for myosin enhancer factor 2 (MEF2). Furthermore, tachypacing induced phosphorylation of HDAC5 and promoted its translocation from the nucleus to cytoplasm, leading to up-regulation of MEF2-related fetal gene expression (β-MHC, BNP). In accord, boosting nuclear localization of HDAC5 by MC1568 or Go6983 attenuated CaT loss in tachypaced HL-1 cardiomyocytes and preserved contractile function in Drosophila prepupae. Findings were expanded to clinical AF. Here, patients with AF showed a significant increase in expression levels and activity of HDAC3, phosphorylated HDAC5 and fetal genes (β-MHC, BNP) in atrial tissue compared to controls in sinus rhythm. Conclusion: Class I and class IIa HDACs display converse roles in AF progression. Whereas overexpression of Class I HDAC3 induces cardiomyocyte dysfunction, class IIa HDAC5 overexpression reveals protective properties. Accordingly, HDAC3 inhibitors and HDAC5 nuclear boosters show protection from tachypacing-induced changes and therefore may represent interesting therapeutic options in clinical AF.