Leading article: The Prime Minister and the limits of personal charm in diplomacy

The visit began inauspiciously, but the Prime Minister's famed charm and a sense of realism on the part of the President of Pakistan seem to have combined to salvage something for both sides.

David Cameron spoke of the "unbreakable" friendship between the two countries; Asif Ali Zardari eschewed grandstanding and thanked Mr Cameron for his understanding of Pakistan's problems; the two planted a tree at Chequers in memory of Mr Zardari's late wife, Benazir Bhutto.

This was about as good as this tricky encounter was going to get. Mr Cameron's perceived slight about Pakistan and terrorism appears not to have overshadowed the talks; co-operation is to be intensified, whether in education or in combating terrorism, and Mr Zardari made suitably Cameronesque noises about Pakistan wanting to do more for itself.

Parallel rows that had threatened to erupt – suspicions that the real purpose of Mr Zardari's visit was to launch the political career of his son, Bilawal, and the argument that he should have remained in Pakistan to oversee flood relief operations – were partially defused. Zardari Jnr decided not to attend the controversial rally in Birmingham, but to open a donation point at the High Commission instead, while the outcry about the floods is something President Zardari will have to confront, in its rightful domestic context, when he returns.

As for other results, the Home Secretary will visit Pakistan in the autumn to discuss such vexed issues as security and visas, while Mr Cameron himself has accepted an invitation to Islamabad within the next half-year. Overall, relations do not look nearly as bad at the end of this week as they did at the start. The question, which will probably not be answered for a while, is how far this is real, and how far it reflects the practised use of diplomatic smoke and mirrors.

If British-Pakistani relations have been successfully rebalanced, however, the week has also afforded glimpses of pitfalls in the diplomatic arena that the Prime Minister must learn to avoid. Mr Cameron is a quick thinker and a fluent speaker – on occasion, perhaps, a mite too quick and fluent for his own good. We are all in favour of plain speaking, and Mr Cameron, we believe, knew exactly what he was doing when he said what he did about terrorism in Pakistan, as indeed when he described Gaza as a "prison camp". While pleasing his hosts, he risked damaging relations with third countries, but it was damage he probably judged he could repair at subsequent personal meetings, as he apparently did with Mr Zardari.

Real gaffes, however – his implied assumption that Iran already had a nuclear weapon and the reference to Britain as a "junior partner" to the US in 1940, and, more seriously, his omission, while in India, of all reference to Kashmir – hint at ignorance or carelessness. Mr Cameron's prompt acknowledgement was the right response, and a novice prime minister can be granted a certain indulgence. The time comes, though, when a political leader has to get his facts right or risk being dismissed as an accident-prone lightweight. Mr Cameron's charmed life may have led him to believe that international relations are less complicated than they are. In that case, the past week may have been a useful corrective.