Prime Minister Indira Gandhi announced tonight that parliamentary elections will probably be held as India in March and said that the emergency restrictions she imposed a year and a half ago were being eased to permit "legitimate" political activity.

Her announcement, broadcast in both Hindi and English, followed by only a few hours the release of one of her main political rivals from detention. Former Deputy Prime Minister Morarji Desai, 80, had been imprisoned under emergency laws since June 1975.

In the eight-minute broadcast, Gandhi said there had already been a "gradual easing" of emergency restrictions, citing a relaxation of censorship on the domestic press and the release of opposition politicians.

But she warned that she was not lifting the state of internal emergency altogether and would not tolerate any disruption.

"May I remind you," she said, "that the emergency was proclaimed because the nation was far from normal. Now that it is being nursed to health, we must insure that there is no relapse."

Elections to the 525-seat lower house, originally due last March, were postponed under emergency rule. In November the government extended the legislature's life for another year, and it had been widely expected that elections would not be held until 1978.

Desai said after the prime minister's broadcast that the relatively short campaign period "puts a hardship on the opposition," adding:

"But I am sure that this sudden declaration of an election will benefit not the prime minister but the nation, which is the only important thing. It is a test for the people. I hope it will be a fair election."

The announcement also followed a government decision today to ease up on the controversial sterilization program spearheaded by Gandhi's younger son, Sanjay, and to concentrate on other methods of birth control in the immediate future.

Observers believe that one reason the government has been reluctant to call elections before now has been its fear that the unpopularity of sterilization in some areas could cost it votes.

The name of Sanjay Gandhi 30, who has emerged as one of the most powerful figures in India since the emergency although he holds no elective office, figures prominently in speculation as to what prompted the decision to call a sudden election.

Some observers believe that the prime minister may want to give the burgeoning Youth Congress, which Sanjay leads, a greater say in national affairs while at the same time easing out Communist supporters and sympathizers in the government.

Another consideration may have been the generally healty rate of the economy, despite some price rises and growing unemployment. With the country holding large food stacks and foreign-exchange reserves many Indians are optimistic that they are entering a new era of prosperity.

The emergency, which included suspending civil liberties, arresting thousands of political opponents and censoring the press, was imposed after a mass movement led by veteran pacifist leader Jayaprakash Narayan and political leaders including Desai called for Gandhi's resignation.

Both Narayan and Desai were arrested hours after the emergency was declared.

Narayan, released last year because of ill health, now lives, isolated and ailing, in the northeastern city of Patna.

Oppositon sources said they would attack not only Gandhi's decision to impose the emergency but measures adopted by Parliament since then, including a constitutional amendment increasing executive branch powers and a press censorship bill.

The emergency was proclaimed two weeks after Gandhi was found guilty of misusing the services of government officials in her own parliamentary election campaign in 1971. Major opposition parties demanded her resignation, but the Supreme Court overturned her conviction in November 1975 after the laws under which she was found guilty were rewritten retroactively.

Many political leaders have been released over the past few months, Deesai, a former finance minister who twice challenged Gandhi for the premiership in the 1960s without success, was among the last to be freed.

He has been mentioned as a possible leader of a united opposition party made up of four non-Communist parties - the Opposition Congress Party, the Hindu nationalist Jan Sangh, the Indian People's Party and the Socialist Party. In past elections, most of its seats with pluralities, while the opposition parties split the majority of votes in nearly all districts.

An opposition spokesman said tonight that "We will go into the elections as a united team with a common policy and program" whether a merger is completed or not.

Gandhi is obviously confident of doing well at the polls, since she has chosen to hold elections when her Congress Party and its former ally, the Communist Party of India, have drifted apart.

The Moscow-line CPI has refused to back Sanjay Gandhi's five-point program of social reforms.

In the last parliamentary elections, in March 1971, the Congress Party won a two-thirds majority in the lower house.