ISLAMABAD, Pakistan — Afghan political leaders publicly warned President Ashraf Ghani not to smile when he came to Pakistan for a global conference on Wednesday, but he soon found that to be hard going.

As the Afghan president stepped off his plane at the Islamabad airport, he was surprised to discover that the greeting party far exceeded the demands of protocol, with the Pakistani prime minister and all of the country’s military chiefs on the red carpet along with many other dignitaries, as an honor guard blasted off a 21-gun salute.

It was the sort of welcome normally reserved for visits from prominent Pakistani allies like the president of China or the king of Saudi Arabia — not the leader of the country next door that has been in a war of words, and from time to time guns, with Pakistan for years now, with a turn for the worse in recent months.

Mr. Ghani had been under intense domestic pressure not even to come, even though he was the co-host, with Pakistan, of an event about Afghanistan called the Heart of Asia conference, attended by every other country in South and Central Asia. The welcome was a clear indication that Pakistan wants to mend the frayed relationship.