Three-year-olds also benefited, having higher scores in a picture vocabulary language acquisition test the longer they had been breastfed.
Exclusive breastfeeding - rather than any level of breastfeeding - had the greatest effect, boosting verbal IQ scores by nearly a point per month.
Seven-year-olds who were exclusively breastfed for the first six months after birth had an almost five point advantage over those who were bottle fed.
A US team of researchers reported the findings in the journal JAMA Pediatrics.
The scientists, led by Dr Mandy Belfort from Boston Children's Hospital, wrote: "Our results support a causal relationship of breastfeeding in infancy with receptive language at age three and with verbal and non-verbal IQ at school age.
"These findings support national and international recommendations to promote exclusive breastfeeding through age six months and continuation of breastfeeding through at least age one year."
The study included 1312 mothers and children who had taken part in Project Viva, a long-term investigation of pregnancy and child health.
A number of factors that might have influenced the results, including home environment and mothers' IQ, were accounted for by the researchers.
Children took part in several tests, including the Peabody Picture Vocabulary Test at age three and the Kaufman Brief Intelligence Test at age seven.
Certain nutrients in breast milk may benefit the developing infant brain, it has been suggested. One of these is docosahexaenoic (DHA), which is abundant in fish.
Part of the research looked at whether mothers' fish consumption was linked to the benefits of breastfeeding. However, the results were non-significant.
In an accompanying editorial, Dr Dimitri Christakis from Seattle Children's Hospital Research Institute, wrote: "The problem currently is not so much that most women do not initiate breastfeeding, it is that they do not sustain it. In the United States, about 70 per cent of women overall initiate breastfeeding, although only 50 per cent of African-American women do. However, by six months, only 35 per cent and 20 per cent, respectively, are still breastfeeding."
Dr Christakis added that workplaces should provide better facilities for breastfeeding mothers, and breastfeeding in public should be "destigmatised".
- PA