Background and Aims: Few longitudinal studies have examined the relationship between food insecurity and substance use. We aimed to investigate this relationship using longitudinal data among women with or at risk for HIV in the United States. Design: Women's Interagency HIV Study (WIHS), a prospective cohort study. Setting: Nine sites across the United States. Participants: A total of 2553 women with or at risk for HIV. Measurements: Semi-annual structured interviews were conducted during April 2013–March 2016. Food security (FS) was the primary predictor, measured using the Household Food Security Survey Module. Outcomes were: any illicit substance use except cannabis; licit or illicit cannabis use; stimulant use (crack, cocaine, or methamphetamine); opioid use (heroin or methadone in a non-prescribed way); and prescription drug misuse (prescription narcotics, amphetamines, or tranquilizers in a non-prescribed way) since the last visit. We used multivariable logistic regression with random effects to examine longitudinal associations of current and previous FS with the outcomes simultaneously, adjusting for socio-demographic factors, HIV serostatus, physical health and health insurance. Findings: Average number of visits was 4.6. At baseline, 71% of participants were HIV-seropositive, 44% reported marginal, low, or very low FS, and 13% were using illicit substances. In adjusted analyses, current low and very low FS were significantly associated with 1.59 [95% confidence interval (CI) = 1.02, 2.46; P = 0.039] and 2.48 (95% CI = 1.52, 4.04; P < 0.001) higher odds of any illicit substance use, compared to high FS, and also with higher odds of cannabis, stimulant and opioid use, exhibiting a consistent dose–response relationship. Marginal, low, and very low FS at the previous visit were associated with 1.66 (95% CI = 1.08, 2.54; P = 0.020), 1.77 (95% CI = 1.14, 2.74; P = 0.011), and 2.28 (95% CI = 1.43, 3.64; P < 0.001) higher odds of current illicit substance use. Conclusions: Food insecurity appears to be longitudinally associated with substance use among US women with or at risk for HIV.