Chronic viral infection induces immunosenescence and systemic low-grade inflammation, leading to worsened long-term outcomes. We sought to explore the short- and long-term effects of chronic viral infection on cardiovascular disease (CVD). Based on UK Biobank data, exposed group was identified as individuals who had chronic virus infection-related hospitalization (IRH). Unexposed group was randomly selected, matched by 5-year age interval, sex, and Charlson comorbidity index at a ratio up to 1:10. Restricted cubic splines were used to model time-varying effects of IRH in nonproportional Cox models. A cut-off value of 5 years was recorded and used in piecewise Cox proportional hazards models as we estimated short- and long-term effects of IRH on CVD. A total of 2826 exposed participants and 28 212 matched unexposed participants were included. Chronic viral IRH was associated with increased risk of CVD (0–5 years: hazard ratio, 1.57 [95% confidence interval: 1.32, 1.87] and 5+ years: 1.31 [1.06, 1.61]). Elevated risk of stroke was only observed within the initial 5-year follow-up (0–5 years: 1.91 [1.30, 2.81]). The short- and long-term associations were observed in herpes or hepatitis virus IRH with risk of CVD (all p < 0.05). Subgroup analysis revealed long-term association between chronic viral IRH and CVD among female (5+ years: 1.68 [1.27, 2.22]) but not among male. The association between chronic viral infection and elevated CVD risk appeared to be stronger among individuals who did not take cholesterol-lowering medication, antithrombotic medication, or certain antihypertensive medications (all p for interaction < 0.05). The risk of CVD event remained persistently higher within and over 5 years following chronic viral IRH, especially in individuals infected with herpes and hepatitis virus.