Americans held hostage by Moslem gunmen in Beirut appeared last night to be nearing the end of their two-week-old ordeal as their captors began preparing them for a journey that would take them from the Lebanese capital to Syria, West Germany and freedom today.

U.S. officials reported in Washington late last night that the 39 Americans taken prisoner aboard TWA Flight 847 on June 14 over Greece and flown to Beirut would be taken overland to the Syrian capital of Damascus.

They reportedly would complete the two-hour drive at midday Damascus time, stay there a few hours and then be picked up by a U.S. Air Force plane that would carry them to Frankfurt, the officials said.

While there was no official confirmation, it appeared that a U.S.-Israeli understanding involving the eventual release of 735 prisoners being held in Israel played a key role in breaking the diplomatic deadlock that had developed around the hostages' ordeal.

There was confusion over whether all 39 hostages from the TWA flight would be transferred to Damascus. The captors also appeared to rule out releasing seven other Americans kidnaped earlier in Lebanon, as was demanded again yesterday by President Reagan in a toughly worded denunciation of terrorism.

Reports that the Lebanese Amal Shiite militiamen who had been holding 36 passengers and three TWA crew members were preparing to transfer them to Syrian control surfaced around 2:20 a.m. today (7:20 p.m. EDT last night) in Beirut and Damascus in an almost casual fashion that contrasted sharply with the drama that has kept the Reagan administration, American public opinion and much of the rest of the world focused on terrorism, retaliation and Middle East politics for the past 15 days.

In Beirut, 32 of the hostages suddenly appeared at a downtown hotel with their Amal captors, who said the Americans should make videotapes for their families and eat a midnight meal together before being sent to Damascus.

Missing from the dinner were the three TWA crew members and four passengers identified by an Amal militia official as U.S. Navy divers. The divers are believed to have been held separately from the other hostages by the extremist Hezbollah forces who evidently staged the hijacking, Washington Post correspondent Christopher Dickey reported from Beirut.

The Amal official who accompanied the 32 suggested that the original hijackers still had control of the seven missing TWA hostages, who might be held as a guarantee that Israel will now move ahead with the release of the 735 detainees most of them Lebanese Shiites, being held in Atlit Prison in Israel. This release has been the captors' principal demand in exchange for the release of the Americans.

U.S. officials in Washington said they expected that all 39 would be transferred to Damascus on the basis of messages received from Syrian President Hafez Assad.

But there was some difference of opinion within the Reagan administration on this issue, and some officials previously had suggested that the group taken off the TWA flight and held separately might be kept as "insurance money" to ensure that Israel met the hijackers' main demand for the release of the prisoners held in Israel.

At about the same time that the hostages appeared for dinner in Beirut, a Syrian offical telephoned an American television producer in Damascus to apologize for having to cancel a meeting scheduled for today because the hostages would be arriving in Damascus at midday. A second official telephoned a different producer to relay the same information, Washington Post correspondent Jonathan C. Randal reported from Damascus.

There was no official confirmation of these reports from the Middle Eastern governments involved or in Washington. But a guarded comment from a White House official, who did not dispute the report or caution against its use, was the first clear indication last night that the chance of an immediate transfer of the prisoners was being taken seriously here.

It was not immediately clear if Israel would now begin the release of the Lebanese detainees, who were taken prisoner in southern Lebanon as security risks by the withdrawing Israeli occupation army and moved to the Atlit Prison in April.

U.S. officials have said the two men who staged the hijacking appeared to have relatives among the detainees. The hijackers earlier had killed U.S. Navy Petty Officer Robert Dean Stethem and released more than 100 other passengers who had been aboard the TWA flight from Athens.

The appearance of a break in the crisis came at the end of a day of contradictory signs of growing optimism in Middle East capitals and tough rhetoric from President Reagan.

In Beirut, Lebanese sources said early in the day that Jean-Claude Aime, a special envoy of the United Nations who has been shuttling among Beirut, Jerusalem and Damascus in the past few days, had worked out a plan that Syria had accepted in principle. That plan was reported to call for the Syrians to take the hostages briefly, while final agreement was reached on Israel's release of the Lebanese detainees.

Diplomatic sources in Jerusalem and Washington suggested that the United States and Israel would continue to deny that any deal had been reached even as the swap began.

In Damascus, reliable sources reported that accommodations were being prepared for the hostages in the event that they were moved.

Earlier, Israeli officials suggested that there had been significant movement yesterday toward an understanding between the United States and Israel on a formula that would lead to the release of the 735 detainees once the 39 American hostages being held in Beirut had been released safely.

These suggestions, conveyed to U.S. journalists in Israel and reportedly also relayed to leading figures in the American Jewish community by the Israeli government, came as President Reagan returned to a tough public line by blasting the "thugs and murderers and barbarians" who took the American hostages, and by insisting that America also was demanding the return of the seven other Americans kidnaped in Lebanon by Islamic extremists demanding the release of terrorists now held in Kuwait.

But the president also sounded a note of optimism. "You know me," Reagan told reporters who asked if he saw progress being made. "I am superstitious. I never talk about a no-hitter if you are pitching one."

But there was still no official confirmation from Syria early today that the informal understanding between Washington and Jerusalem linking the liberation of the Americans with Israel subsequently freeing its prisoners was specific and far-reaching enough to get Syria involved in guaranteeing a swap.

In Beirut, the chief Moslem negotiator, Nabih Berri, had insisted earlier that the release of the American hostages and the Arab prisoners in Israel had to be simultaneous. Aides to Berri also saw American insistence that the seven Americans kidnaped during the past 15 months in Lebanon by Hezbollah extremists would complicate an agreement on the 39 TWA hostages.

Despite these obstacles, Berri continued to predict that the hostages could be released this weekend.

Diplomatic sources in Washington suggested that Assad had set a deadline for his country's participation in an exchange by letting it be known that he would leave on an official trip to Czechoslovakia on July 2.

Reagan's decision to talk publicly, and toughly, about the hostage crisis again after the White House had imposed a three-day blackout on public comment came on a day when reports that Israel and the United States had reached an understanding over the hostages and broken a deadlock circulated through Washington.

That deadlock centered on Israel's reluctance to be seen to give in to terrorist demands by releasing the Lebanese prisoners in Israel without a formal request from the United States to do so and Reagan's stated refusal to encourage terrorism by making such demands.

Concern appeared to grow in Israel and in the American Jewish community yesterday that the hostage crisis was beginning to create political problems between Washington and Jerusalem after a senior White House official was quoted by The Washington Post as saying that Israel already should have understood that the administration wanted the Arab prisoners freed.

In responding to questions about that story in Jerusalem, Israeli officials acknowledged for the first time that a linkage between the Arab detainees and the American hostages had been established in conversations between the United States and Israel.

They stated that linkage in a negative form -- that Prime Minister Shimon Peres' coalition government had come to an understanding with the Reagan administration that Israel would not release the Lebanese Shiites and other prisoners demanded by the hijackers until all the American hostages were safe.

In Washington, there were indications that Israel also had agreed that the Arab detainees would be released in rapid sequence following the liberation of the hostages.

Previously, Israel had said that it had intended to release the Arabs, detained as security risks, as conditions in southern Lebanon permitted and would stick to that schedule.

Reagan, who gave his strong denunciation of the hijackers in a press conference in Chicago, was also responding to another day of emotional pleas on television from some of the hostages, who called on the American public yesterday to urge Reagan to ask Israel to release the Arab detainees and thereby open the way for the release of the Americans.

Asked about the statements on television by hostage spokesman Allyn Conwell in Beirut, Reagan told reporters that terrorists and their supporters "must and will be held to account" and reiterated that the United States would not urge Israel to give in to the demands.

But he also noted that "Israel had always intended to release them, and had made that very clear. So a linkage that has tied it to our hostatges is something that never should have happened."

Berri continued his skillful use of international telephone links and American television's competitive desire to interview the hostages to try to generate public pressure in the United States on the Reagan administration to meet the hijackers' demands.

He spoke to Conwell's wife, Olga, by telephone during a televised interview and pledged that he would "take care of your husband . . . . I am sorry that this happened."

In yesterday's television interviews, Conwell, a Houston-based oil company employe who works in the Arab sultanate of Oman, and Berri established that while Berri's Amal militiamen have sole custody of the 36 American hostages being held in Beirut residences, they are not making any important decisions about the hostages without the approval of the original hijackers.

"I don't have control of the 39," Berri told Olga Conwell. "I have responsibility for them."

The hijackers, whom Conwell termed "terrorists" during a telephone conversation with Dan Rather of CBS television, are believed to belong to the extremist Islamic movement headed by Hezbollah, the Party of God, which follows the political line of Iran's Ayatollah Ruhollah Khomeini.

Conwell disclosed that Berri had approached "the original hijackers" to get permission to have Simon Grossmayer, 57, of Algonquin, Ill., examined and considered for release. Grossmayer is a cancer patient who has only one lung.

Beirut radio reports that Grossmayer had been released early in the day were subsequently denied by Berri, who said he had asked the International Committee of the Red Cross to examine Grossmayer before a decision is reached on releasing him.

Conwell went to some lengths to distinguish the brutal treatment the original hijackers had meted out to the hostages from the way in which Amal was handling them. But the strains of captivity were evident on Grossmayer, who told an Agence France-Presse correspondent as he and Conwell left Berri's house:

"Let's go home. Let's stop this. It's no picnic."