ISLAMABAD - Pakistani Prime Minister Imran Khan and Afghan President Ashraf Ghani held their first face-to-face talks Friday on the sidelines of an annual summit of Islamic countries in Saudi Arabia.

The rare interaction at the highest level is the latest sign of easing tensions in traditionally acrimonious relations between the neighbors.

The animosity stems from mutual accusations of supporting militant attacks against each other.

An Afghan presidential spokesman said the meeting in the Saudi city of Makkah was a prelude to Ghani's official visit to Islamabad scheduled for next month. The Afghan leader has previously visited Pakistan but the upcoming trip will be his first since Khan took office last August.

"Afghanistan is ready to leave its bitter history with Pakistan behind, and move toward constructive state-to-state ties based on mutual respect rather than recrimination and hostility," tweeted spokesman Samim Arif.

A Pakistani foreign ministry statement said that both Khan and Ghani agreed on the need to work closely for intensifying cooperation on such issues as energy, security, trade, and cultural collaboration.

The prime minister, it said, reaffirmed Pakistan's commitment to a peaceful and stable Afghanistan. "He reiterated the belief that an Afghan-owned and Afghan-led peace process was indispensable for a political solution," the statement added.

Pakistani Prime Minister Imran Khan attends a summ Pakistani Prime Minister Imran Khan attends a summit meeting of the 57-member Organization of Islamic Cooperation (OIC) in the Saudi holy city of Mecca, June 1, 2019. Pakistani Prime Minister Imran Khan attends a summit meeting of the 57-member Organization of Islamic Cooperation (OIC) in the Saudi holy city of Mecca, June 1, 2019.

Earlier this week, Afghan national security advisor, Hamadullah Mohib, visited Pakistan where he held extensive discussions with the country's military chief, General Qamar Javed Bajwa, on bilateral security matters and Afghan peace.

Afghan officials routinely allege leaders and fighters of the Taliban use sanctuaries on Pakistani soil to orchestrate insurgent activities inside Afghanistan.

Islamabad rejects the charges and, in turn, accuses Kabul of providing shelter and support to anti-state militants plotting cross-border attacks in Pakistan.

Pakistani officials take credit for arranging ongoing negotiations between the United States and the Taliban to help promote a negotiated settlement to the deadly Afghan war.

The months-long dialogue, however, has not offered any major breakthrough.

The Taliban wants a complete withdrawal of U.S.-led foreign forces from Afghanistan before it stops fighting and engages in intra-Afghan peace talks.

Washington insists a final agreement must cover not only a troop withdrawal timetable, but a ceasefire by the Taliban and their engagement in talks with the Kabul government.