The militant Moslem students occupying the U.S. Embassy in Tehran yesterday agreed to turn their captives over to the Iranian government, but arrangements for the physical transfer of the hostages remained to be worked out.

A year after invading the embassy and seizing its personnel, the militants asked Prime Minister Mohammed Ali Rajai to appoint a representative to take "delivery of the American spies." Plans to shift the hostages to government control were to be worked out at a meeting later between militants and government officials. Meanwhile, Iranian officials said, the 52 captive Americans would stay where they are.

A spokesman for Rajai said later that no decision had been made on whether to move the hostages or on who should guard them, Reuter news agency reported from Tehran last night. It was not clear what any decision to transfer the hostages physically to government control would involve, and there were no signs of activity all day yesterday at the occupied U.S. Embassy.

Three of the hostages have been held in the Iranian Foreign Ministry for the past year, but the whereabouts of the other 49 were not known for certain. The militants claim to have dispersed them, but U.S. authorities believe most are still in the embassy.

The militants announced their decision to give up their hostages after a meeting with Ayatollah Ruhollah Khomeini, who gave the move his blessing. It was the first time that Khomeini had unambiguously approved the transfer of the hostages to government control and appeared to signal his acquiescence to the parliament's decision Sunday to seek a settlement of the hostage issue with the United States.

Khomeini conferred with the militants yesterday morning in a two-hour meeting in a mosque next to his home in the northern Tehran suburb of Jamaran. He told them that it was "a correct move to delegate the issue to the government" and expressed his thanks for "the service which these young people rendered."

A spokesman for Rajai said the prime minister met yesterday morning with Algerian Ambassador Abdel Karim Gheraieb and asked Algeria to take charge of Iran's end of the hostage issue, including the delivery of the parliament's conditions for release to the U.S. government. The spokesman said that Rajai also asked Algeria to organize the actual release of the hostages once a settlement has been reached and to decide on their destination, the French news agency Agence France-Presse reported from Tehran.

In a separate meeting, Rajai met with the Swiss and West German ambassadors, Iran's official Pars News Agency reported. It said Swiss Ambassador Erik Lang gave Rajai a letter from President Carter, but the agency did not disclose the letter's contents.

A Swiss Embassy spokesman quoted by Reuter described the letter as a first reaction to the parliament's action on the hostage issue. He stressed that it was not a reply to the conditions, which had not yet been officially transmitted to Washington.

Algeria represents Iran's interests in Washington, and Switzerland handles U.S. interests in Tehran.

Rajai's office said the Iranian government did not plan to deal directly with the United States on settling the hostages issue. In a television interview, Rajai said that an interministerial commission had been appointed to "act in order to free the hostages in accordance with developments on the meeting of Iran's proposed conditions, Reuter reported.

The commission includes senior Foreign Ministry officials and is headed by Behzad Nabavi, the minister of state for executive affairs. Nabavi accompanied Rajai on his trip to New York to address the United Nations last month. Dressed in an army fatigue jacket, Nabavi frequently whispered advice in Rajai's ear as the prime minister answered press questions.

During their meeting yesterday in which Khomeini approved the militant's offer to give up the hostages, neither the ayatollah nor the students who call themselves the followers of his line showed any contrition or inclination to tone down their rhetoric.

"Now a year has passed since the conquest of the American den of espionage and the holding of the hostages, a year which has been a source of pride for the valiant and fighting Islamic nation, a year of disgrace for the great Satan, a year of pride," a statement issued by the militants said.

The statement said that the parliament's decision on conditions for the hostages' release "does not mean the end of the conflict with America . . . . We shall fight against world-devouring America till we die."

The militants said they wanted to join the war to repel invading Iraqi forces "to teach a lesson to all America's puppets."

The statement concluded: "Therefore, if the great leader of the revolution grants us permission, we will from now on delegate the responsibility for the hostages to the government and will engage in the most important current issue of the revolution, defense of the Islamic homeland."

Khomeini told the militants in reply that the occupation of the embassy was "worth any hardship which our nation might endure and worth any difficulty and impasse it might face. It had a political value beside which all other values are insignificant."

Despite the harsh rhetoric, the developments seemed to signal movement toward an actual release of the hostages. Buoyed by this prospect, the U.S. dollar strengthened on all European money markets yesterday.

There was still no indication when the release of the hostages could occur, however, and Carter administration sources said the appointment of the Iranian commission under Nabavi could mean protracted haggling over the implementation of Iran's conditions, should the United States decide to meet them.

Another subject of doubt was the current status of the 52 Americans held in Iran. After a U.S. attempt to rescue the hostages in April, the militants announced the dispersal of their captives to at least 15 cities and towns across Iran in an effort to prevent any such attempt in the future. Following the outbreak of war with Iraq on Sept. 22 and an Iraqi air raid on Tehran, the militants said the hostages were being moved again to unspecified locations.

Some diplomats in Tehran believe the Americans held by the militants have been moved back to Tehran, but it was not known whether they were at the 27-acre embassy compound in downtown Tehran or somewhere else. Throughout the year of captivity, the embassy has been guarded by armed Revolutionary Guards, although at times the security has seemed lax.

The chain of events leading to the current situation began Sept. 12, when Ayatollah Khomeini listed four terms for the Americans' release: the unfreezing of Iranian assets, the cancellation of all U.S. claims against Iran, the return of the late shah's property and a promise not to interfere in Iranian affairs. Khomeini announced the conditions almost in passing in a speech to Moslems setting off for the hajj, the annual pilgrimage to Mecca.

According to news reports from Tehran, the United States responded quickly in a letter sent through diplomatic channels to President Abol Hassan Bani-Sadr. The letter reportedly set out the U.S. position on the four terms and explained what Washington could and could not do to meet them. The sticking point as far as Washington was concerned was said to be the return of the shah's wealth.

On Oct. 2, after a series of parliamentary sessions that included discussion of the hostage issue, the assembly set up a seven-member commission to recommend conditions for the Americans' release. There were many conflicting reports about what the commission would conclude, with some legislators insisting that demands for a U.S. apology and other concession would be added, and others saying that the panel would stick to Khomeini's suggestions.

Complicating the deliberations on the hostages was the outbreak of the war between Iran and Iraq. The two countries' warplanes raided each other's capitals and Iraqi ground forces invaded the southwestern Iranian oil-producing province of Khuzestan.Despite its declaration of neutrality, the United States was caught in the middle as each side accused Washington of backing the other.