The two Muslim countries have witnessed bombings blamed on extremist groups in recent months.
"Turkey and Pakistan are determined to efficiently maintain their joint stance against terrorism," Turkish President Ahmet Necdet Sezer told a news conference held jointly with Musharraf on Tuesday.
The "anti-terror" agreement provides for exchanges of information and experts, Musharraf said.
Several of the Muslim groups blamed for the November car bomb attacks in Istanbul, which left 62 dead and hundreds injured, were said to have received training in camps in Pakistan.
In an address to the Turkish parliament, the Pakistani leader warned that "the gap of misunderstanding between the West and the Islamic world is growing" because of a surge in Muslim extremism.
He said Muslims should denounce religious militancy and focus on social and economic development, calling on the Western world, particularly the United States, to help in such efforts.
Both Turkey and Pakistan have close ties with the West and are allies of the US in its declared war on global "terrorism".
Officials from the two sides also signed agreements on economic partnership and preferential trade, along with accords on cooperation in the banking and health sectors.
Dozens of Turks were killed and
hundreds hurt in recent bombings
"I'm sure these agreements will strengthen and fortify the already close and brotherly relations between Turkey and Pakistan," Musharraf said.
Trade between the two countries has been about $160 million to $170 million a year over the past five years.
The objective, Musharraf has said, is to increase the bilateral trade volume to one billion dollars by 2005.
The Pakistani leader, on his first visit abroad since two attempts on his life last month by Islamists, also discussed regional issues such as Iraq, Afghanistan and Cyprus, as well as the recent thaw in relations between his country and India.
"Pakistan and India cannot be enemies forever. It is an imperative that the Jammu Kashmir dispute is resolved peacefully," Musharraf said.
Turkey and Pakistan have enjoyed traditionally warm ties for decades.
Musharraf, who spent part of his youth in Ankara where his father was posted as a diplomat, has frequently held Turkey up as a model of an ideal liberal and secular Muslim country.
The Pakistani leader won applauses in the parliament when he delivered parts of his speech in Turkish.
He was to meet with Prime Minister Recep Tayyip Erdogan later in the day and travel on to Istanbul on Wednesday for a meeting with Turkish business people.
After wrapping up his visit, Musharraf will head to the World Economic Forum in Davos, Switzerland, on Thursday.