Nawaz Sharif's victory in Pakistan's general elections is being seen with some alarm in Afghanistan, where some fear it may mean more instability.
The fact that the Pakistani Taliban held off attacking Mr Sharif's Pakistan Muslim League (N), and the comments he made during the election campaign, reinforced the perception in Afghanistan that Nawaz Sharif is a "representative of the Pakistani establishment" which Afghans blame for most of their troubles.
Nawaz Sharif has suggested that Pakistan should end its support for the international alliance against terrorism and says he would talk to Pakistani militant groups.
Many Afghans fear he will make peace with the Pakistani Taliban, who will then stop carrying out attacks in Pakistan and focus solely on Afghanistan.
"Nawaz Sharif wants peace in Pakistan at the expense of stability in Afghanistan," says Rahmatullah, a resident of the western Afghan province of Herat.
"He doesn't want a stable and strong Afghanistan."
The roots of these concerns lie in the past.
Mr Sharif was very close to Pakistan's former military ruler General Zia-ul-Haq, who was behind organising Afghan resistance to Soviet occupation in the 1980s. Both Gen Zia and Mr Sharif had close links with all seven Afghan mujahideen factions based in Pakistan.
This policy resulted in the fall of the Soviet-backed regime in Kabul in 1992.
As prime minister of Pakistan, Nawaz Sharif was instrumental in forming the mujahideen government in Peshawar, before sending it over the border to take power in Kabul.
Mr Sharif went to Kabul just a day after the mujahideen victory on 28 April 1992, the first and only foreign leader to visit.
Many in Afghanistan blame him for dismantling the Afghan security forces and fulfilling the mission of bringing Afghanistan into "Pakistan's sphere of influence".
In the run-up to Pakistani elections in October 1993, Nawaz Sharif's party occasionally taunted its rival, the PPP of Benazir Bhutto, by using the slogan "you gave up Dhaka, we took Kabul".
This was a reference to the PPP governing Pakistan when Bangladesh (formerly East Pakistan) seceded in 1971, while it was under the PML that the Pakistan-based mujahideen leaders were installed in Kabul.
The Taliban emerged in Afghanistan when Benazir Bhutto was Pakistan's prime minister. But it was Nawaz Sharif's government that officially recognised the Taliban government in Kabul on 25 May 1997.
In addition, as prime minister Mr Sharif openly praised the Taliban and its policies in Afghanistan during his failed attempts to introduce Sharia law in Pakistan through a constitutional amendment in 1998.
Although the party was out of power for 14 years, it has kept the relationship alive with some Afghan stakeholders, including the Hezb-e-Islami of Gulbuddin Hekmatyar, the leader of a powerful mujahideen faction that is now part of the Afghan insurgency and whose representatives are engaged in on-off talks with the government in Kabul.
Afghan President Hamid Karzai was the first foreign leader to welcome Mr Sharif's election. He praised Pakistan for holding general elections despite the violence.
In a phone conversation with Mr Sharif, President Karzai expressed his hope that relations between the two countries would improve with the sincere co-operation of Pakistan in the war on terrorism.
Although the two leaders don't have a personal relationship, they have a few things in common. Both are devout Muslims and both had a shared goal of ending the Soviet occupation of Afghanistan.
Afghan officials generally accuse Pakistan of sponsoring the Taliban in Afghanistan and have frequently asked Pakistan to dismantle what they call militant sanctuaries on its soil.
The Afghan government wants the new administration in Pakistan to formulate a clear policy towards brokering peace in Afghanistan by pressurising or convincing Taliban leaders, who Kabul says are all based in Pakistan.
Leaders of the PML (N) reject the pro-militant accusations made against the party.
"Afghanistan will feel the change that Pakistan now has a strong and popular government," Sartaj Aziz, a member of the PML (N)'s powerful central executive committee and a former foreign minister during Mr Sharif's second term, told the BBC.
"Bilateral relations will improve because we both have the same goal of achieving peace and the formation of a stable government [in Afghanistan] as a result of reaching some sort of reconciliation following the withdrawal of the US."
Unlike President Asif Ali Zardari's outgoing PPP government, which was trusted by neither the Pakistani army nor the Taliban, Nawaz Sharif has the potential to become a guarantor and mediator for peace talks.
He has already reached out to Pakistan's arch-rival India and indicated that he wants to revive the peace process he undertook with Delhi when he was last in power.
Good relations between India and Pakistan will have a positive impact on the situation in Afghanistan, where India's growing influence is viewed with concern in Islamabad.
Nawaz Sharif now has a mandate from the people of Pakistan and is respected and possibly feared by both the army and Afghan and Pakistani militant and religious groups.
In addition, he is also close to Saudi Arabia, one of only three countries (the other two being Pakistan and the United Arab Emirates) that recognised the Taliban when they were in power.
Saudi Arabia is still an important regional player and can influence Pakistan's Afghan policy and play an effective role in brokering peace between the Afghan government and the Taliban.
All this puts Nawaz Sharif in a much better position than his predecessors to help curb militancy and bring long-awaited peace to both Pakistan and Afghanistan.
He says his top priority is the economy - for Pakistan to prosper he needs peace and stability not only in his own country but also in the neighbourhood.
But don't expect change overnight - Pakistan's powerful military is unlikely to cede Afghan policy easily to the new civilian administration.