Pakistani and Afghan diplomats made "substantive progress" at United Nations-sponsored talks in Geneva last month aimed at getting Soviet troops out of Afghanistan, but the "core issue" of a timetable for the withdrawal remains to be tackled, Pakistan's Foreign Minister Sahabzada Yaqub Khan said here today.

Nonetheless, Yaqub Khan expressed "cautious optimism" and said in an interview that there appeared to a new mood in Moscow for a political settlement that could end the Soviet Union's five-year occupation of Afghanistan.

The timetable for a withdrawal of Soviet troops, which would be part of an interrelated four-part package that would include guarantees of Afghan security by Washington and Moscow, will be the key item when a fifth round of proximity talks are held in Geneva Aug 27.

"If those talks go well," said Yaqub Khan, "we will have gone beyond clearing the decks for action." Pakistan's foreign minister, here for talks on improving his country's relations with neighboring India, presented one of the more optimistic appraisals of the Soviet Union's willingness to withdraw its more than 110,000 troops from Afghanistan since Moscow invaded in December 1979 and installed Babrak Karmal as president.

Yaqub Khan cited the quickened pace of the talks, which resumed in late June after a lapse of two years, as one basis for his optimistic view.

He credited the new Indian attitude of Prime Minister Rajiv Gandhi as "a positive factor" in moving the talks forward. Gandhi said after his return from Moscow in May that he detected a new, serious interest by the Soviet leadership in negotiations that could lead to a neutral, nonaligned Afghanistan.

Indian sources indicated during Gandhi's visit to Washington a month ago that the Indian prime minister had received hints from Soviet leader Mikhail Gorbachev and other Soviet officials of a change in the Kremlin's attitude toward its drawn-out struggle in Afghanistan.

But Gandhi has declined to say whether, as a result of his talks with Gorbachev in Moscow and President Reagan in Washington, India would take a more active role in the Afghan peace process.