India and Pakistan moved toward a no-war pact today as the foreign ministers of the two neighboring states agreed that three days of talks here had cleared mutual fears and misunderstandings that threatened to drag them into a fourth armed conflict.

Pakistani Foreign Minister Agha Shahi appeared to have succeeded in easing some Indian doubts about the sincerity of his country's September offer of a treaty of nonaggression and nonuse of force, which New Delhi had considered a potential trap.

"The air has been sufficiently cleared to facilitate specific considerations that could constitute the substance of such an agreement," the two foreign ministers said in a joint communique. "A measure of mutual understanding was reached on a number of these elements."

As a result of this new understanding, Indian Foreign Minister P. V. Narasimha Rao told a joint press conference that talks had started on the substance of a no-war pact that "will lead us to a stage where the object of his Agha Shahi's visit will be achieved."

Shahi made it clear upon arrival Friday that more talks will be needed before agreement can be reached on a no-war pact, and the foreign ministers delegated their chief aides to continue the negotiations later this month in Islamabad.

Beyond that, three less substantive agreements were struck as a visible indication that the talks had been fruitful.

Pakistan agreed to India's proposal to set up a joint commission to meet regularly to discuss bilateral issues; Pakistan opened two more religious shrines to Indian pilgrims, and both countries decided to make fresh efforts to locate soldiers missing in action from past wars although it appeared unlikely any would be found.

It was a small miracle that the two nations could come even this far in forswearing war against each other, considering the fear and paranoia in both countries over the past year.

New Delhi, for instance, firmly held the view that Pakistan, buoyed with new weapons it was buying from the United States, was just waiting for the chance to exact vengeance for the last war more than a decade ago when India helped dismember Pakistan through the creation of Bangladesh. Futhermore, the government here made no secret of its belief that the martial law regime of President Mohammed Zia ul-Haq would go to war against India to gain popular support to remain in power.

Underlying those fears, diplomats here said, was frustration over Washington's aid to Pakistan, which India felt threatened its preeminent position in South Asia.

In Pakistan, government officials and the public alike are convinced that Indian Prime Minister Indira Gandhi has not reconciled herself to the existence of Pakistan and would provoke a war to keep herself in power in the face of a worsening domestic economic and political situation.

No assurances by the leader of either country seem able to dispel those widely held beliefs and it is clear that a vast gulf remains between the two nations that have fought three wars since they were carved from British India and given independence 34 years ago.

There was, for instance, no discussion by the foreign ministers of a mutual disengagement from a cease-fire line along a disputed boundary in Kashmir where Indian and Pakistani troops face each other on a war footing.

Clear differences remain over the motives for Pakistan's purchase of arms from the United States including the F16 fighter-bomber.

Shahi was reported, however, to have assured India that entering into a weapons deal does not mean the country is giving bases to the United States or joining in Secretary of State Alexander M. Haig Jr.'s "strategic consensus" against Soviet expansionism in the Persian Gulf.

The renewed ties between the United States and Pakistan--who agreed this fall to a $3.2 billion, six-year arms sale and economic aid deal--appear more than anything else to have aroused India's fears about Pakistan.

Gandhi repeatedly claims that Pakistan has always used its arms against India. In an interview with Pakistani journalists covering the talks, she blamed Pakistan for starting all three wars--a claim Pakistan and many independent observers would dispute.

Friday, Shahi directly addressed what he called "doubts and misgivings" on the part of India about Pakistan's arms purchases from the United States, which he said arose from "exaggerated reports about the number of aircraft to be received."

When he left today he said his greatest accomplishment was "in at least diminishing the doubts and suspicions held by our Indian friends."

But in today's press conference he insisted that the no-war pact would not stop Pakistan from getting any arms from any source that it considered necessary for its security.

Keeping to the spirit of cordiality that marked the talks, however, he avoided opportunities he has taken in the past to point up India's large arms purchases on highly advantageous terms from the Soviet Union, as well as its other recent weapons deals with Britain, France and West Germany.

Considering the state of relations between India and Pakistan, which began deteriorating two years ago over the different responses to the Soviet invasion of Afghanistan and worsened as the United States drew closer to Islamabad, most observers here were surprised at how well the talks went.

Officially, the talks were described as having been conducted "in an atmosphere of frankness, warmth and cordiality"--diplomatic language indicating a positive approach. Both sides appeared intent on avoiding the kind of ritualistic irritants that have blocked serious negotiations in the past.