Morarji Desai, 81-year-old leader of the successful fight to unseat Indira Gandhi, was sworn in today as India's fourth prime minister and immediately signaled a possible end to this country's special links with the Soviet Union.

At a news conference after taking the oath of office, Desai said the 1971 Indian-Soviet friendship treaty "must not come in the way of our friendship with any other state . . . We don't have any special relations with any country."

Desai, a veteran of the Indian independence movement and a former leader of Gandhi's Congress party, said his government would adopt a foreign policy of "proper nonalignment.

In the wide-ranging news conference, he also said his government does "not believe in atomic weapons at all," said he would ban all forced sterilizations and stressed freedom of the press. He said that constitutional amendments passed last year, which undercut the judiciary, strengthened the executive and institutionalized the harsh emergency measures Gandhi imposed, would be repealed.

In Washington, U.S. officials expressed pleasure at Desai's selection. After a meeting between Indian Ambassador Kewal Singh and Secretary of State Cyrus Vance, a State Department spokesman said the United States was "deeply impressed" with the democratic election process in India and the smooth transfer of power there.

"Relations are very good and prospects for further improvement are excellent," the spokesman said.

In Moscow, the Soviet government moved to put some distance between itself and the Gandhi government, with which it had maintained warm relations.

Desai was sworn in as prime minister by acting President B. D. Jatti in a simple three-minute ceremony at the red sandstone presidential palace that was the residence of the British viceroys in the colonial era. The event marked the end of Congress Party rule for the first time since India won independence in 1947.

When reporters at the news conference took note of Desai's advanced age, he said he would quit the prime ministership "the day I feel I am not physically fit."

"I'll vacate immediately, even tomorrow," he added. "I'm not going to stay a moment longer than I'm needed. But what does age matter? It's the spirit that matters."

In a procedure that sparked immediate dissensions among the political parties that united to oust Mrs. Gandhi's Congress Party in last week's general elections, Desai was handpicked for the top post by two other aging disciples of independence.

Jayaprakash, 89, made their choice after conferring with some of the lawmakers belonging to the victorious People's Party headed by Desai and the Congress for Democracy led by former Agriculture Minister Jagjivan Ram.

Political sources said Narayan and Kripalino had agreed to evolve a "censensus" on the prime ministership the People's Party and its ally to soon after winning the election on a pledge to cooperate.

As soon as Narayan and Kripalani announced that they favored Desai, Ram's followers said they would stay out of the new government, but would support it in Parliament on an issue by-issue basis.

Without the support of the Congress for Democracy's 28-seat bloc in Parliament, the People's Party could have trouble remaining in power.

By itself the People's Party has 270 seats, two short of a majority although it claims the support of various regional parties that hold another 30 seats.

The danger is that the popular Ram, outside the government, could capitalize on any dissatisfaction within the party. One of the party's general secretaries, Ram Dhan, resigned his party office tomight to protest the way Desai was picked.

Desai said tonight that the four groups that came together to form the People's Party would formally merge soon. The four are the Opopsition Congress Party, a splinter of the ruling Congress Party; the Indian People's Party, the Hindu nationalist Jan Sangh Party and the Socialists.

All but the Socialists have been regarded as being to the right of center, but ideological lines have blurred in India particularly since the declaration of a state of emergency in June 1975.

On censorship, Desai said he hopes that there would be more than one news agency and that radio and television would not limit themselves to government news.