Indian Prime Minister Indira Gandhi, in her sharpest attack on Pakistan to date, has accused Pakistan directly and the United States by implication of deliberately blocking an agreement that would allow the Soviet Union to withdraw its troops from Afghanistan.

"I think that Pakistan does not want a solution," she said, declaring that it has benefited from being a front-line state in East-West confrontation.

"They are taking the fullest possible advantage of it in every way, and I think even the much bigger countries think that it is a good idea that the Soviet Union should be engaged at various points," Gandhi said.

Western diplomats interpreted this comment as a reference to the Reagan administration's policy of selling arms to Pakistan to bolster its defenses against the 85,000 Soviet troops on its borders.

Gandhi's sharp denunciation of Pakistani policies came in an interview with the Paris newspaper Le Figaro. The text was released here by the Ministry of External Affairs.

Her attack comes at at a time of increased diplomatic activity aiming at a political solution of the 22-month-old Afghan crisis.

On Aug. 24 the Moscow-installed government of Babrak Karmal gave in to some of the conditions Pakistan has laid down as a basis for talks.

But the new Afghan proposal failed to address the major Pakistani point: its objection to talks with the Babrak government directly, on the ground that dealing with it would legitimize the Soviet-installed Kabul regime. Instead, Pakistan is willing to talk to Babrak and his associates as members of the ruling party.

Afghan Foreign Minister Shah Mohammed Dost told Gandhi when he visited here earlier this week that Kabul is "flexible" on procedural matters in trying to find a political solution.

Nonetheless, the Afghans do not seem willing to give in on that key point and remain insistent on talking to Pakistan as a government.

Dost is echoing a theme of flexibility that has come also from Moscow in what some Western diplomats here viewed as an attempt by the Soviet Union and its allies to short-circuit a possible third United Nations General Assembly condemnation of the Soviet Union's invasion of Afghanistan in December 1979.

Western diplomats here pointed out that previous Soviet and Afghan initiatives for a political solution have coincided with major international meetings where condemnations of the Soviet invasion were on the agenda.

The Gandhi government has abstained on the two U.N. votes, maintaining that it does no good to condemn the Soviet Union.

At the same time, it repeatedly insists that it has told top Soviet leaders that its troops should be withdrawn from Afghanistan.

In her interview in Le Figaro, Gandhi praised the Afghan government as being "sincere" in its desire for a political solution.

Eastern European diplomats here have gone out of their way to tell Western correspondents that the United States should take the Afghan proposal seriously.

The Gandhi government is known to believe that Pakistan has taken advantage of the Soviet troops next door to gain new American and Western European aid as well as increased status within the Islamic world.

Before the Soviet invasion, Pakistan was for all practical purposes isolated in the world. Its economy was a shambles, international aid was drying up and there were no prospects of American economic help, let alone military sales. The invasion of Afghanistan changed all that.

The Soviets insisted they moved their troops into already Marxist Afghanistan to help the government there defend itself against rebel bands supplied through Pakistan by the United States and China. Moscow has said it will pull its troops out once the danger to the Kabul government has passed.

The government appears to have become less stable since the Soviets moved in, however, with the rebel bands becoming stronger and bolder. Moreover, the Babrak government appears to have only limited popular support, and the ruling People's Democratic Party of Afghanistan has become even more widely split than before.