Afghan President Hamid Karzai hailed ties with China on Friday, describing it as a stabilising force in the region and world during talks with the country's leaders.
Karzai, who had attended an economic conference in the northern city of Xian, held talks in Beijing with China's President Xi Jinping and Premier Li Keqiang.
The meeting came as China has boosted its diplomacy with Afghanistan since last year ahead of a planned withdraw of US-led Nato troops in 2014.
"We consider China to be an anchor of stability for this region and the larger world," Karzai told Li during the hour-long talks.
Later, Karzai was given an an elaborate welcoming ceremony at central Beijing's ornate Great Hall of the People, including a 21-gun salute, ahead of the start of talks with Xi.
"The trust of our friendship has been tested and approved," Karzai said, noting he has visited the country five or six times over the past 12 years.
Xi told Karzai his visit came at an "important time and affords an important opportunity for interaction with the new leadership of China".
Li told the Afghan president he had "played an important leadership role in leading the people of Afghanistan in their peace and reconstruction efforts".
Ministers from both sides also signed agreements on extradition and economic and technical cooperation.
In September last year Beijing sent its highest-ranking official to visit Kabul in nearly half a century, the security chief at the time Zhou Yongkang.
China has secured major oil and copper mining concessions in the country, which is believed to possess minerals worth more than $1 trillion.
Other regional players such as India and Iran have also begun scrambling for influence ahead of the troop pullout. China and Afghanistan share a short border of 76 kilometres (47 miles).
Karzai visited Beijing in June 2012 where he attended a meeting of the Shanghai Cooperation Organisation, during which Afghanistan was granted observer status.
The grouping led by China and Russia is meant to counterbalance US and Nato influence in the region.