Sudden cardiac death exhibits diurnal variation in both acquired and hereditary forms of heart disease, but the molecular basis of this variation is unknown. A common mechanism that underlies susceptibility to ventricular arrhythmias is abnormalities in the duration (for example, short or long QT syndromes and heart failure) or pattern (for example, Brugada's syndrome) of myocardial repolarization. Here we provide molecular evidence that links circadian rhythms to vulnerability in ventricular arrhythmias in mice. Specifically, we show that cardiac ion-channel expression and QT-interval duration (an index of myocardial repolarization) exhibit endogenous circadian rhythmicity under the control of a clock-dependent oscillator, krüppel-like factor 15 (Klf15). Klf15 transcriptionally controls rhythmic expression of Kv channel-interacting protein 2 (KChIP2), a critical subunit required for generating the transient outward potassium current. Deficiency or excess of Klf15 causes loss of rhythmic QT variation, abnormal repolarization and enhanced susceptibility to ventricular arrhythmias. These findings identify circadian transcription of ion channels as a mechanism for cardiac arrhythmogenesis.