The leaders of China and Pakistan have pledged to work against separatist Muslims in China's north-western Xinjiang province.
General Musharraf is discussing military and economic links
At a summit meeting in Beijing they also signed a number of deals, but no agreement has yet emerged on Chinese help towards building a nuclear power plant in Pakistan.
The summit comes amid a background of warming ties between China and Pakistan's regional rival, India.
It is the first meeting between the Pakistani President, Pervez Musharraf, and his Chinese counterpart, Hu Jintao, who came to power in March.
The BBC's correspondent in Beijing, Louisa Lim, says Mr Hu hailed General Musharraf as an old friend of the Chinese people.
State-run television in China reported that General Musharraf said Pakistan stood resolutely against terrorism and would not allow anti-China forces to use Pakistan as a base.
This was in reference to Uighur Muslims in China's north-western Xinjiang province bordering Pakistan.
The two sides signed deals including an extradition treaty and a preferential trade agreement but there was no sign of a deal on Chinese assistance towards building a nuclear power plant in Pakistan - Beijing's second such venture.
Pakistani press reports had said that the financing and technical agreements would be thrashed out during the visit.
The US wants China to stop its nuclear co-operation with Pakistan, but both Beijing and Islamabad insist it is not for military purposes.
As well as holding talks with President Hu, General Musharraf will also meet former leader Jiang Zemin, who still heads China's military.
General Musharraf's visit follows one made to Beijing in June by Indian Prime Minister, Atal Behari Vajpayee.
The BBC diplomatic correspondent Barnaby Mason says the days are gone when Pakistan could take its alliance with China for granted, in the knowledge that Chinese-Indian relations were stuck in the deep freeze.
Pakistan has been worried by signs of a closer relationship between Beijing and Delhi.
But China remains Pakistan's biggest arms supplier, an essential prop in the face of India's huge conventional superiority.
After visiting China, General Musharraf will head to South Korea for talks with President Roh Moo-hyun.