The evolution of influenza viruses is fundamentally shaped by within-host processes. However, the within-host evolutionary dynamics of influenza viruses remain incompletely understood, in part because most studies have focused on within-host virus diversity of infections in otherwise healthy adults based on single timepoint data. Here, we analysed the within-host evolution of 82 longitudinally sampled individuals, mostly young children, infected with A/H3N2 or A/H1N1pdm09 viruses between 2007 and 2009. For A/H1N1pdm09 infections during the 2009 pandemic, nonsynonymous changes were common early in infection but decreased or remained constant throughout infection. For A/H3N2 viruses, early infection was dominated by purifying selection. However, as the A/H3N2 infections progressed for longer-than-average duration (up to 2 weeks) in relatively young or influenza naive individuals, nonsynonymous variants increased in frequencies even though within-host virus titres decreased, leading to the maintenance of virus diversity via mutation-selection balance and provide important opportunities for within-host virus evolution.