Background: People living with HIV are at risk of increased myocardial infarction (MI). Cumulative HIV viral load (VL) has been proposed as a better measure of HIV inflammation than other measures of VL, like baseline VL, but its associations with MI are not known. Methods: The multisite Centers for AIDS Research Network of Integrated Clinical Systems (CNICS) cohort includes clinical data and centrally adjudicated MI with distinction between atheroembolic MI (type 1) and MI related to supply-demand mismatch (type 2). We examined CNICS participants who were not on antiretroviral therapy (ART) at enrollment. Cumulative VL (copy-days of virus) from 6 months after enrollment was estimated with a time-weighted sum using the trapezoidal rule. We modeled associations of cumulative and baseline VL with MI by type using marginal structural Cox models. We contrasted the 75% percentile of the VL distribution with the 25% percentile. Results: Among 11,324 participants, 218 MIs occurred between 1996 and 2016. Higher cumulative VL was associated with risk of all MI (hazard ratio [HR] = 1.72; 95% confidence interval [CI] = 1.26, 2.36), type 1 MI (HR = 1.23; 95% CI = 0.78, 1.96), and type 2 MI (HR = 2.52; 95% CI = 1.74, 3.66). While off ART, cumulative VL had a stronger association with type 1 MI (HR = 2.13; 95% CI = 1.15, 3.94) than type 2 MI (HR = 1.25; 95% CI = 0.70, 2.25). Baseline VL was associated with all MI (HR = 1.60; 95% CI = 1.28, 2.01), type 1 MI (HR = 1.73; 95% CI = 1.26, 2.38), and type 2 MI (HR = 1.51; 95% CI = 1.10, 2.08). Conclusions: Higher cumulative and baseline VL is associated with all MI, with a particularly strong association between cumulative VL and type 2 MI.