Background: Previous randomised trials of bivalirudin versus heparin in patients with ST-segment elevation myocardial infarction (STEMI) undergoing primary percutaneous coronary intervention (PCI) have reported conflicting results, in part because of treatment with different pharmacological regimens. We designed a large-scale trial examining bivalirudin with a post-PCI high-dose infusion compared with heparin alone, the regimens that previous studies have shown to have the best balance of safety and efficacy. Methods: BRIGHT-4 was an investigator-initiated, open-label, randomised controlled trial conducted at 87 clinical centres in 63 cities in China. Patients with STEMI undergoing primary PCI with radial artery access within 48 h of symptom onset who had not received previous fibrinolytic therapy, anticoagulants, or glycoprotein IIb/IIIa inhibitors were randomly assigned (1:1) to receive bivalirudin with a post-PCI high-dose infusion for 2–4 h or unfractionated heparin monotherapy. There was no masking. Glycoprotein IIb/IIIa inhibitor use was reserved for procedural thrombotic complications in both groups. The primary endpoint was a composite of all-cause mortality or Bleeding Academic Research Consortium (BARC) types 3–5 bleeding at 30 days. This trial is registered with ClinicalTrials.gov (NCT03822975), and is ongoing. Findings: Between Feb 14, 2019, and April 7, 2022, a total of 6016 patients with STEMI undergoing primary PCI were randomly assigned to receive either bivalirudin plus a high-dose infusion after PCI (n=3009) or unfractionated heparin monotherapy (n=3007). Radial artery access was used in 5593 (93·1%) of 6008 patients. Compared with heparin monotherapy, bivalirudin reduced the 30-day rate of the primary endpoint (132 events [4·39%] in the heparin group vs 92 events [3·06%] in the bivalirudin group; difference, 1·33%, 95% CI 0·38–2·29%; hazard ratio [HR] 0·69, 95% CI 0·53–0·91; p=0·0070). All-cause mortality within 30 days occurred in 118 (3·92%) heparin-assigned patients and in 89 (2·96%) bivalirudin-assigned patients (HR 0·75; 95% CI 0·57–0·99; p=0·0420), and BARC types 3–5 bleeding occurred in 24 (0·80%) heparin-assigned patients and five (0·17%) bivalirudin-assigned patients (HR 0·21; 95% CI 0·08–0·54; p=0·0014). There were no significant differences in the 30-day rates of reinfarction, stroke, or ischaemia-driven target vessel revascularisation between the groups. Within 30 days, stent thrombosis occurred in 11 (0·37%) of bivalirudin-assigned patients and 33 (1·10%) of heparin-assigned patients (p=0·0015). Interpretation: In patients with STEMI undergoing primary PCI predominantly with radial artery access, anticoagulation with bivalirudin plus a post-PCI high-dose infusion for 2–4 h significantly reduced the 30-day composite rate of all-cause mortality or BARC types 3–5 major bleeding compared with heparin monotherapy. Funding: Chinese Society of Cardiology Foundation (CSCF2019A01), and a research grant from Jiangsu Hengrui Pharmaceuticals.