NEW YORK — The number of children in the U.S. foster care system has dropped for the first time since 2012, stemming a surge that was linked to substance abuse by parents, according to new federal data released on Thursday.

The annual report from the Department of Health and Human Services counted 437,283 children in foster care as of Sept. 30, 2018, down from about 441,000 a year earlier.

The peak was 524,000 children in foster care in 2002. The number dropped steadily to about 396,000 in 2012 before rising again as the opioid epidemic and other forms of drug abuse began to worsen across the U.S.

The new data also showed that a record 63,100 children were adopted out of the U.S. child welfare system in the 2018 fiscal year, up from 59,500 in 2017.

However, the number of children in foster care waiting to be adopted also increased, rising from 123,754 to 125,400.

HHS officials said they were encouraged by the slight decrease in the number of children in foster care. They credited the expansion of prevention programs aimed at supporting families before a need arises to remove a child from their home.

"We hope to see a continued indication that child welfare systems are relying less on foster care and serving more children and families in their home and communities," said Jerry Milner, associate commissioner of HHS's Children's Bureau.

The biggest decreases in the foster care population occurred in Arizona and Indiana, which were among the states where the numbers had soared earlier in this decade.

Parental neglect was the most common reason for children to be removed from their homes in 2018 — a factor in placing about 163,500 children into foster care. About 94,400 children were removed because of parental substance abuse, up from 92,100 in 2017.

About 10% of foster children were residing in institutions or group homes at the close of the 2018 fiscal year — down from 14% in 2015 and reflecting new policies aimed at reducing the use of so-called congregate care.

About 17,000 youths in their late teens aged out of the system in 2018 without being placed with permanent families.

During the surge in the foster care population, many state child welfare agencies struggled to recruit an adequate number of foster parents.

A recent survey by the Chronicle of Social change, which tracks foster-care trends nationwide, found that the total number of licensed foster homes in the U.S. had increased from 2018 to 2019. However, the Chronicle said the number of licensed homes declined by more than 10% in 11 states.