U.S. Defense Secretary Ash Carter and Turkish President Recep Tayyip Erdogan Friday discussed the need to increase military cooperation between the two countries in the campaign to defeat Islamic State in Syria and Iraq.

Carter arrived Friday in Ankara, Turkey, where he met with Erdogan and other top Turkish political and defense officials.

A U.S. Defense Department statement said the leaders agreed to maintain frequent communication and close coordination among members of the coalition fighting the Islamic State terror group, to ensure a "lasting defeat" of IS.

Carter’s trip to Ankara comes as the U.S. is increasingly worried about tensions between Turkey and Iraq surrounding the campaign to retake the Iraqi city of Mosul from IS fighters.

Turkish troops

Turkey wants to have a larger role in the battle for Iraq’s second city, but the Iraqi government is opposed to Turkish military involvement, and the U.S. fears tensions between the two countries could lead to the end of an agreement that is keeping rival sectarian and ethnic militias out of Mosul.

Before he arrived in Turkey, Carter said he would emphasize the need for Turkey to respect Iraq's sovereignty.

The Turkish and Iraqi governments have been feuding about the presence of Turkish troops at the Bashiqa camp north of Mosul, where 500 Turkish soldiers have been training Sunni and Kurdish fighters since last December.

The Iraqi government has said the troops don’t have permission to be at the base and called for them to leave, though Turkey has refused and said the soldiers will take part in the operation to retake Mosul.

Carter also toured the Turkish parliament building that was damaged during the July coup attempt and expressed condolences to those who were killed defending the Turkish government.

"I think everyone there admires the heroes and the martyrs of that terrible incident. We are your strong friends, your long time allies and staunch supporters of the great democracy in Turkey," Carter said.

(Story was updated to clarify wording of U.S. statement mentioned in 3rd paragraph.)