WASHINGTON — Federal immigration agents apprehended just over 42,500 people at the southwestern border in June, according to data released on Thursday by the Department of Homeland Security, a drop in the number of migrants trying to enter the United States after a spike the previous three months.

Border Patrol agents arrested 34,114 people trying to enter the country while customs officers at ports of entry denied entry to 8,451 people, including families and children who showed up at the border alone, the numbers show.

About 5,562 unaccompanied children showed up at the border in June, while 12,192 people traveling in family groups were denied entry, the data shows.

The apprehension statistics show a drop in the number of people trying to enter the country after the numbers exceeded more than 50,000 in each of the three months before June. That came after a year in which the numbers of people apprehended had dropped to a more-than 40-year low.