Pakistan has a historic relationship with Iran, but an agreement was far from certain, writes the BBC’s Caroline Davies