An epidemic model with distributed time delay is derived to describe the dynamics of infectious diseases with varying immunity. It is shown that solutions are always positive, and the model has at most two steady states: disease-free and endemic. It is proved that the disease-free equilibrium is locally and globally asymptotically stable. When an endemic equilibrium exists, it is possible to analytically prove its local and global stability using Lyapunov functionals. Bifurcation analysis is performed using DDE-BIFTOOL and traceDDE to investigate different dynamical regimes in the model using numerical continuation for different values of system parameters and different integral kernels.