Background: Data on patients with COVID-19 who have cancer are lacking. Here we characterise the outcomes of a cohort of patients with cancer and COVID-19 and identify potential prognostic factors for mortality and severe illness. Methods: In this cohort study, we collected de-identified data on patients with active or previous malignancy, aged 18 years and older, with confirmed severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) infection from the USA, Canada, and Spain from the COVID-19 and Cancer Consortium (CCC19) database for whom baseline data were added between March 17 and April 16, 2020. We collected data on baseline clinical conditions, medications, cancer diagnosis and treatment, and COVID-19 disease course. The primary endpoint was all-cause mortality within 30 days of diagnosis of COVID-19. We assessed the association between the outcome and potential prognostic variables using logistic regression analyses, partially adjusted for age, sex, smoking status, and obesity. This study is registered with ClinicalTrials.gov, NCT04354701, and is ongoing. Findings: Of 1035 records entered into the CCC19 database during the study period, 928 patients met inclusion criteria for our analysis. Median age was 66 years (IQR 57–76), 279 (30%) were aged 75 years or older, and 468 (50%) patients were male. The most prevalent malignancies were breast (191 [21%]) and prostate (152 [16%]). 366 (39%) patients were on active anticancer treatment, and 396 (43%) had active (measurable) cancer. At analysis (May 7, 2020), 121 (13%) patients had died. In logistic regression analysis, independent factors associated with increased 30-day mortality, after partial adjustment, were: increased age (per 10 years; partially adjusted odds ratio 1·84, 95% CI 1·53–2·21), male sex (1·63, 1·07–2·48), smoking status (former smoker vs never smoked: 1·60, 1·03–2·47), number of comorbidities (two vs none: 4·50, 1·33–15·28), Eastern Cooperative Oncology Group performance status of 2 or higher (status of 2 vs 0 or 1: 3·89, 2·11–7·18), active cancer (progressing vs remission: 5·20, 2·77–9·77), and receipt of azithromycin plus hydroxychloroquine (vs treatment with neither: 2·93, 1·79–4·79; confounding by indication cannot be excluded). Compared with residence in the US-Northeast, residence in Canada (0·24, 0·07–0·84) or the US-Midwest (0·50, 0·28–0·90) were associated with decreased 30-day all-cause mortality. Race and ethnicity, obesity status, cancer type, type of anticancer therapy, and recent surgery were not associated with mortality. Interpretation: Among patients with cancer and COVID-19, 30-day all-cause mortality was high and associated with general risk factors and risk factors unique to patients with cancer. Longer follow-up is needed to better understand the effect of COVID-19 on outcomes in patients with cancer, including the ability to continue specific cancer treatments. Funding: American Cancer Society, National Institutes of Health, and Hope Foundation for Cancer Research.