Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, said at the Halifax International Security Forum Saturday that the increased presence of military troops at the U.S.-Mexico border is "not to deny access to migrants."

President Trump said before the midterm elections that he would order the deployment of up to 15,000 military personnel to the border as a show of force against a caravan of migrants approaching the southern border. More than 5,000 troops have been deployed so far.

Dunford said military personnel were there to provide engineering support to points of entry, and to provide logistical and medical support to customs and border police.

Get Breaking News Delivered to Your Inbox

"The tasks that we are providing are in support of the Department of Homeland Security. And nothing that we are doing is illegal," Dunford said. "What we are doing now in support of customs and border police and Homeland Security more broadly is filling legitimate capability gaps that they have with military capabilities."

Joint Chiefs Chairman Gen. Joseph Dunford listens on Capitol Hill in Washington. Jacquelyn Martin/AP

Dunford said that the migrants would not face American soldiers upon crossing the border.

"Our job is not to deny access to migrants into the United States. Our job is to support the Department of Homeland Security in doing their job," Dunford said.

Democrats have criticized Mr. Trump's decision to deploy military troops to the border, believing his emphasis on the caravan before the election was a campaign ploy.