BEIRUT, Lebanon — Lebanon began transporting an estimated 400 armed Islamic State fighters and family members from its northern border to the militants’ stronghold in eastern Syria on Monday, according to official sources in Lebanon and Syria.

The militants were transferred as part of a deal between the Islamic State, also known as ISIS or ISIL, and its Syrian and Lebanese enemies. Under the agreement, the bodies of eight people believed to be Lebanese soldiers were to be returned, while Islamic State militants were to receive 17 air-conditioned buses, 11 ambulances and a free pass through territory held by the Syrian government.

Hezbollah, the Shiite-dominated group whose militia was among the parties to the deal, announced through its War Media Center that the transfer of the Islamic State fighters had begun on Monday morning. First to go were 25 wounded fighters in ambulances, followed by busloads of fighters and others.

The Syrian state news agency, SANA, also confirmed that the transfer of fighters was underway.

Maj. Gen. Abbas Ibrahim, the Lebanese intelligence chief who was the government’s chief negotiator in trying to win the return of Lebanon’s captured soldiers, defended the arrangement.