With terrorist forces now threatening it at home and overseas, India has turned full circle from its previously passive attitude toward acts of violence by extremist groups.

In a move that surprised the U.S. Embassy here, Prime Minister Rajiv Gandhi attacked the hijacking of a TWA jetliner by Shiite Moslems and called for the immediate relase of the American hostages.

"We were pleasantly surprised by it. You know they usually don't do that," an embassy spokesman said today.

The statement on the TWA hijacking last week followed a strong condemnation of international terrorism in the final communique issued by Gandhi and President Reagan at the end of Gandhi's visit to Washington.

Both the communique and the Gandhi statement contrasted markedly with India's past positions on terrorist incidents around the world.

New Delhi rarely condemned hijackings, especially when they were committed on behalf of Arab interests. India allowed a group headed by Murtaza Bhutto, the son of executed Pakistani former president Zulfiqar Ali Bhutto, to pass through Bombay after it had hijacked a Pakistan International Airlines plane to Kabul, Afghanistan, and then on to Damascus, Syria, in 1981.

When Iranian fundamentalists seized the U.S. Embassy in Tehran in 1979, India sent a trade mission to get business and help Iran overcome economic sanctions imposed by the United States and its Western European allies.

J.D. Sethi, a former member of the planning commission here, pointed out in an article in The Indian Express last December that India has condemned only a "handful" of the 774 incidents of international terrorism that took place in 1983.

"India must completely reverse its outdated and self-defeating policy of either conniving in or condoning hundreds of acts of terrorism enacted by all kinds of groups," he concluded.

Among the acts of terrorism in this region that India remained silent on, Sethi continued, was the assassination by North Koreans of 17 persons, including four South Korean Cabinet ministers, in a bomb blast in the Burmese capital of Rangoon in 1983.

All this has changed as a new consciousness has developed here on the effects of terrorism, an Indian diplomat here said yesterday.

The change came as international terrorism has been brought forcefully to the Indian nation with a series of assassinations, including the Oct. 31 slaying of Indira Gandhi, mother of Rajiv Gandhi, by Sikh extremists who were members of her police guard. In addition, it is widely believed here that an Air-India jet was downed Sunday by a bomb planted by Sikh terrorists.

There have also been assassinations of foreign diplomats here and of an Indian diplomat in Britain that are believed to have been committed by terrorist groups.

Indian diplomats in countries such as Sri Lanka and Canada, where there have been terrorist threats against them, are accompanied by bodyguards.

Sikh extremists, fundamentalist members of a 500-year-old religion combining elements of Hinduism and Islam, brought turmoil to India's breadbasket of the Punjab with assassinations of those opposed to a separate Sikh state in northern India. The victims included mainstream political leaders and journalists of both the Sikh and Hindu religions.

While India has accused Pakistan of aiding the Sikh terrorists, India, in turn, has been blamed by Sri Lanka for allowing Tamil extremists seeking a separate state in Sri Lanka free run of southern India as a base to launch attacks.

While not acknowledging that India helped the separatists, Prime Minister Gandhi reported that his government has put pressure on the Tamil extremists to stop their terrorist tactics.

In what is seen by western diplomats here and in the Sri Lankan capital of Colombo as an unusually constructive role by India in dealing with political problems of its South Asian neighbors, Gandhi has pressured the Tamils to stop fighting and begin talks with the government of Sri Lankan President Junius R. Jayewardene to achieve a political solution. The talks are aimed at giving the minority Tamils, who are mostly Hindus, more local autonomy in that primarily Sinhalese Buddhist nation.

Gandhi revealed this month that his government has intercepted $4 million worth of arms that were being funneled through the southern Indian city of Madras to Tamil separatist groups that have been reported by western intelligence sources to be running open training camps in the southern Indian state of Tamil Nadu.

According to western diplomats in Colombo, the arms shipment was discovered by intelligence officers of the central government who realized that the weapons were likely to slip by Indian state officials, also Tamils, who are sympathetic to the separatist cause.