In this paper, we describe a Gaussian wave-based state space to model the temporal dynamics of electrocardiogram (ECG) signals. It is shown that this model may be effectively used for generating synthetic ECGs as well as separate characteristic waves (CWs) such as the atrial and ventricular complexes. The model uses separate state variables for each CW, i.e. P, QRS and T, and hence is capable of generating individual synthetic CWs as well as realistic ECG signals. The model is therefore useful for generating arrhythmias. Simulations of sinus bradycardia, sinus tachycardia, ventricular flutter, atrial fibrillation and ventricular tachycardia are presented. In addition, discrete versions of the equations are presented for a model-based Bayesian framework for denoising. This framework, together with an extended Kalman filter and extended Kalman smoother, was used for denoising the ECG for both normal rhythms and arrhythmias. For evaluating the denoising performance, the signal-to-noise ratio (SNR) improvement of the filter outputs and clinical parameter stability were studied. The results demonstrate superiority over a wide range of input SNRs, achieving a maximum 12.7 dB improvement. Results indicate that preventing clinically relevant distortion of the ECG is sensitive to the number of model parameters. Models are presented which do not exhibit such distortions. The approach presented in this paper may therefore serve as an effective framework for synthetic ECG generation and model-based filtering of noisy ECG recordings.