Background: Structural lung disease and neutrophil-dominated airway inflammation is present from 3 months of age in children diagnosed with cystic fibrosis after newborn screening. We hypothesised that azithromycin, given three times weekly to infants with cystic fibrosis from diagnosis until age 36 months, would reduce the extent of structural lung disease as captured on chest CT scans. Methods: A phase three, randomised, double-blind, placebo-controlled trial was done at eight paediatric cystic fibrosis centres in Australia and New Zealand. Infants (aged 3–6 months) diagnosed with cystic fibrosis following newborn screening were eligible. Exclusion criteria included prolonged mechanical ventilation in the first 3 months of life, clinically significant medical disease or comorbidities other than cystic fibrosis, or macrolide hypersensitivity. Participants were randomly assigned (1:1) to receive either azithromycin (10 mg/kg bodyweight orally three times per week) or matched placebo until age 36 months. Randomisation was done with a permuted block strategy and an interactive web-based response system, stratified by study site. Unblinding was done once all participants completed the trial. The two primary outcomes were the proportion of children with radiologically defined bronchiectasis, and the percentage of total lung volume affected by disease. Secondary outcomes included clinical outcomes and exploratory outcomes were inflammatory markers. Analyses were done with the intention-to-treat principle. This study is registered at ClinicalTrials.gov (NCT01270074). Findings: Between June 15, 2012, and July 10, 2017, 281 patients were screened, of whom 130 were enrolled, randomly assigned, and received first study dose. 68 participants received azithromycin and 62 received placebo. At 36 months, 88% (n=50) of the azithromycin group and 94% (n=44) of the placebo group had bronchiectasis (odds ratio 0·49, 95% CI 0·12 to 2·00; p=0·32), and total airways disease did not differ between groups (median difference −0·02%, 95% CI −0·59 to 0·56; p=0·96). Secondary outcome results included fewer days in hospital for pulmonary exacerbations (mean difference −6·3, 95% CI −10·5 to −2·1; p=0·0037) and fewer courses of inhaled or oral antibiotics (incidence rate ratio 0·88, 95% CI 0·81 to 0·97; p=0·0088) for those in the azithromycin group. For the preplanned, exploratory analysis, concentrations of airway inflammation were lower for participants receiving azithromycin, including interleukin-8 (median difference −1·2 pg/mL, 95% CI −1·9 to −0·5; p=0·0012) and neutrophil elastase activity (−0·6 μg/mL, −1·1 to −0·2; p=0·0087) at age 36 months, although no difference was noted between the groups for interleukin-8 or neutrophil elastase activity at 12 months. There was no effect of azithromycin on body-mass index at age 36 months (mean difference 0·4, 95% CI −0·1 to 0·9; p=0·12), nor any evidence of pathogen emergence with the use of azithromycin. There were few adverse outcomes with no differences between the treatment groups. Interpretation: Azithromycin treatment from diagnosis of cystic fibrosis did not reduce the extent of structural lung disease at 36 months of age; however, it did reduce airway inflammation, morbidity including pulmonary exacerbations in the first year of life and hospitalisations, and improved some clinical outcomes associated with cystic fibrosis lung disease. Therefore we suggest thrice-weekly azithromycin is a strategy that could be considered for the routine early management of paediatric patients with cystic fibrosis. Funding: Cystic Fibrosis Foundation.