Clashes erupted betwen Hindus and Sikhs today within hours of the assassination of Prime Minister Indira Gandhi by two of her bodyguards, who were reported to be Sikhs, as the government moved quickly to establish a sense of political continuity in the world's largest democracy and second most populous nation.

Rajiv Gandhi, 40, the prime minister's only surviving son, was unanimously elected at an emergency Cabinet meeting to succeed her and was sworn in by President Zail Singh, himself a Sikh. Rajiv Gandhi quickly issued an appeal for calm.

"In this hour of crisis," he said, "we should not allow passions to cloud our judgment and wisdom. There cannot be a better tribute to Mrs. Gandhi than a peaceful India," he said in his first address as prime minister.

Indira Gandhi, 66, was struck down as she emerged from her official residence at 9:20 a.m. (10:50 p.m. Tuesday EST) to meet visitors, including British actor Peter Ustinov, who were to interview her. According to a spokesman, two bodyguards shot her seven times as she was walking between her residence and a bungalow used as an office. The spokesman said security forces overpowered the gunmen; one died and the other is hospitalized with wounds.

The assassination appeared to be the culmination of of tensions stemming from the two-year campaign of violence by extremist Sikh nationalists seeking an autonomous state. Mainstream Sikhs, meanwhile, have been pressing more moderate demands for increased rights.

In June, Gandhi ordered the Indian Army to storm the Golden Temple in Amritsar, the holiest site in the Sikh religion, to root out extremists headquartered there. The attack on the sacred site, in which as many as 1,000 Sikhs and Army troops reportedly were killed, outraged Sikhs in India and elsewhere.

After the shooting today, Gandhi was rushed to the All-India Institute of Medicine three miles away, where a team of 12 doctors operated on her wounds. Unofficial sources at the hospital reported that she was clinically dead on arrival at the facility, but she was officially reported to have died at 2:30 p.m. (4 a.m. EST).

Later today the government declared a 12-day period of mourning and announced that her funeral and cremation will be Saturday. Gandhi's body will lie in state at a museum that once was the home of her father, Jawaharlal Nehru, India's first prime minister. In Washington, Secretary of State George P. Shultz was named to lead the U.S. delegation to the funeral.

Thousands of mourners forming a line nearly a mile long appeared early Thursday morning to view Gandhi's body, Washington Post correspondent William Claiborne reported.

As Rajiv Gandhi stood by, mourners filed past the bier on which his mother's body, covered with flowers, rested.

Some mourners wept and a few women chanted prayers, but for the most part the crowed walked slowly past the bier without outward emotion, Claiborne reported.

The area around the museum was cordoned off by hundreds of police. The streets of New Delhi were virtually deserted except for the mourners walking slowly toward Teen Murti House, as the museum is known.

President Reagan, who was awakened at 3 a.m. with news of Gandhi's death and later paid a condolence call at the Indian Embassy with Shultz, joined a chorus of world leaders denouncing the assassination, the most momentous act of political violence in India since the 1948 assassination of Mohandas K. (Mahatma) Gandhi, champion of India's nonviolent drive for independence.

The five high priests of the Sikh religion condemned the assassination of Gandhi, a Hindu, as did leaders of the Akali Dal, the moderate political party of the Sikhs. But in Punjab State, where most of India's Sikhs live, other Sikhs distributed sweets to celebrate her death, which they viewed as retribution for the storming of the Golden Temple.

Police and other officials reported that the prime minister's killers were Sikhs, and a caller to The Associated Press in New Delhi said the assassination was a Sikh act of vengeance.

"We have taken our revenge," the caller said. Long live the Sikh religion."

The man, who refused to identify himself, said, "This is the action of the entire Sikh people," AP reported.

Political leaders, Cabinet members and police reached the hospital soon after the shooting, and as the news spread, a crowd of several thousand gathered.

"She is no more," a Congress-I Party official announced to the throng outside, which erupted into tears and cries of anger.

Rajiv Gandhi, who had been on a campaign swing in West Bengal, returned to the capital to view her body at the hospital. Maneka Gandhi, Indira Gandhi's estranged daughter-in-law, also went to the medical center and issued a statement denouncing the assassination.

After Gandhi's death was announced, clashes between Hindus, who form the majority religion in India, and Sikhs, a breakaway Hindu sect making up about 2 percent of the population, broke out in New Delhi and elsewhere.

Outside the hospital in New Delhi, crowds went on a rampage immediately, burning cars and trucks belonging to Sikhs and and setting fire to several Sikh temples. One person was killed and several injured. There were other clashes elsewhere in the city, and tonight the government imposed restrictive orders in the capital. Another person was reported killed in Calcutta.

Violence was reported in at least seven states, according to the Press Trust of India, and curfews were imposed in Agartala, capital of northeastern Tripura State, Jammu in northern Jammu and Kashmir State and Jabalpur in Madhya Pradesh, the news agency said.

In Bombay, angry crowds shouted anti-Sikh slogans outside a Sikh temple.

In Kerala, a statewide strike reportedly began as huge crowds took to the streets and blocked trains in the main railway station in Trivandrum, the state capital.

Indian troops throughout the country went on alert, and border patrols were stepped up. Troops moved into Punjab, the nation's breadbasket, its richest state and heartland of the Sikh religion in India.

Today in Punjab, Sikhs angry at attacks against their brethren in other parts of the country attacked Hindus and set Hindu shops and houses on fire.

Army troops also patrolled Agartala, in Tripura State, and Calcutta city tonight after rampaging crowds took to the streets to protest Gandhi's murder, and the Press Trust of India reported that angry crowds forced shops to close in the southern city of Bangalore.

After the Golden Temple incident, threats against the prime minister increased and security around her, her son and other top officials was tightened. A special commando force was set up to guard the country's top leaders.

The prime minister's advisers had counseled her not to include Sikhs in the commando force, but Gandhi vetoed the advice, reportedly saying that she could not afford to be perceived to distrust any particular Indian community.

The two alleged assassins both had the Sikh name of Singh, but the prime minister's press secretary refused to confirm police and other officials' statements that they were Sikhs, apparently in an attempt to curb violence against the Sikh community.

"It is not for me to say if the attackers were Sikhs," H.Y. Sharada Prasad said.

One of the assailants, sub-inspector Beant Singh, had been working on Gandhi's security staff for eight years, and constable Satwant Singh, a young Sikh, reportedly was taken onto the security staff on Beant Sing's recommendation. Beant Singh "used to drive her grandchildren to school every day," said a senior member of Gandhi's household.

Beant Singh, according to police sources, was in the Army before he joined the New Delhi police, and was discharged from the military on disciplinary grounds. "He was never known to have any communal feeling," said one of his colleagues.

One of the two assailants was said by official sources to have been on leave in recent weeks in an area of Punjab that had been a stronghold of extremist Sikh leader Jarnail Singh Bhindranwale, who died in the attack on the Golden Temple.

Beant Singh reportedly was originally scheduled for the evening shift, but switched with a colleague to a morning shift on the plea that he had some personal work to do in the evening. He fired first at Gandhi from his revolver.

The Press Trust of India reported tonight that the entire security contingent at the prime minister's compound was undergoing interrogation about possible links to the killing.

Intelligence sources claimed they had reports of a possible attempt on the prime minister's life and had warned the security staff to have all her appointments for today canceled.

Newspapers quoted a speech Gandhi made in Orissa yesterday as indicating that she had a premonition of her death. Addressing a mammoth public meeting to round off her tour there, Gandhi had said in an emotional tone that even if she died in the service of the nation, she would be proud of it.

"Every drop of my blood, I am sure, will contribute to the growth of this nation and to make it strong and dynamic," Gandhi affirmed.

As Gandhi, wearing an orange sari, emerged from her home into the bright sunshine this morning, one of her bodyguards drew his service revolver and fired at her, according to press secretary Prasad. As she slumped to the ground, another of her guards, opened fire with a Sten submachine gun.

Actor Ustinov, who with an Irish film crew was scheduled to interview her for a television series on world leaders, said "total chaos" followed at the compound, a wooded and fenced complex.

For hours after the assassination, "no one seemed to be in charge," he said, adding that he and the crew were never allowed close to the spot where Gandhi fell and that they were detained until officials satisfied themselves that the assassination had not been recorded or filmed by the crew.

The choice of Rajiv Gandhi to succeed his mother and become India's sixth and youngest prime minister was made by party leaders at a hastily called Cabinet session. Political analysts said the choice reflected party leaders" hopes that the Gandhi name, and Rajiv Gandhi's reputation for political probity, will carry the Congress-I (for Indira) party to victory in parliamentary elections due in January.

Rajiv Gandhi, an initially reluctant political newcomer, was tapped by his mother four years ago after the death of his younger and more politically seasoned brother Sanjay in an airplane crash. A former airline pilot, he won a parliamentary seat and was one of the secretaries of Congress-I, set up by Gandhi in 1978.

He is the third member of the Nehru family to become prime minister.

Rajiv Gandhi faces pressing challenges in dealing with the resentment of India's Sikhs, which was compounded over the summer by the Army's stay in Punjab and accompanied by reports of military excesses. Sikhs are heavily represented in the Army, where incidents of mutiny were reported in the aftermath of the Golden Temple assault, and also occupy high government positions.

Other possible flash points for India's new leader include the far northeastern state of Assam, where 3,000 to 5,000 people died in massacres in February of last year during electoral clashes between indigenous Hindus and mostly Moslem immigrants from Bangladesh.

Sectarian violence has plagued India since independence in 1947 when the partition of the subcontinent into India and Pakistan led to a vast migration of Hindus, Moslems and Sikhs across both borders and the deaths of at least half a million people in the accompanying violence.

Earlier this year, clashes in Bombay between Hindus, who make up 83 percent of India's population, and Moslems, who make up 11 percent, killed 400 persons.

A desire for more autonomy from central government rule persists in other states, and in the northeast, where the population is ethnically different from the rest of India, insurgents continue their campaign for independence.