A U.S. Air Force C141 jet transport carrying 39 American ex-hostages touched down here just after dawn today, ending their 17-day ordeal in the hands of Shiite gunmen and a final 13-hour journey to freedom that began yesterday afternoon in a ramshackle Beirut schoolyard.

On the tarmac at the huge U.S. Rhein-Main Air Base here to greet them was Vice President Bush and a bipartisan delegation of four U.S. senators.

"You displayed character and spirit," Bush told the arriving hijacking victims, and "endured this cruel experience with courage. America is proud of you."

Bush recalled the "brutal murder" of a young Navy man, Robert Dean Stethem, and added that "somewhere in Lebanon, other Americans are still prisoners," a reference to seven others kidnaped by Shiite extremists in the past year.

Just beyond stood scores of family members who had flown here to be united with their missing husbands, sons and brothers. Hundreds of other base personnel carrying balloons and hand-painted posters joined the crowd.

The gathered families, the television crews jostling for position, the "welcome home" banner strung across the control tower were all eerie reminders of a scene here more than four years ago when another planeload of Americans from another chaotic Middle Eastern country, Iran, were delivered here from the hands of other religious extremists who had held them and their country hostage.

From Beirut, Washington Post correspondent Christopher Dickey reported, the hostages had traveled overland to Damascus, Syria, in a bizarre convoy of Red Cross station wagons and sedans escorted by gun-wielding members of several different Moslem militias and Syrian troops on a route that dramatized the disintegration of Lebanon from a nation into war-ravaged fiefdoms.

In Damascus, before boarding the Air Force jet for Frankfurt, Allyn Conwell, who has emerged as spokesman for the hostages, told reporters how "we're all eagerly anxious to get home and hug our loved ones and touch American soil," Washington Post correspondent Jonathan Randal reported.

"For anyone and everyone who has prayed for us, talked for us, waited for us, hoped for us, we thank you," he said at a packed televised press conference in the Syrian capital.

Their ordeal ended after intense American and Syrian diplomacy Saturday night, combined with what appears to have been direct Syrian muscle applied to the hijackers who were holding four Americans separately from the others, resolved a last-minute snag that had stalled their release.

Nabih Berri, the leader of Lebanon's more moderate Amal militia, who stepped into the crisis as a negotiator, said in Beirut that the hijackers had agreed to release the hostages after private assurances from Syrian President Hafez Assad that Israel would release 735 detainees, mostly Lebanese Shiites, whose freedom had been the hijackers' main demand.

The Israeli Cabinet met yesterday and discussed the situation as the hostages were being brought together in a battered Beirut schoolyard before their release. Cabinet Secretary Yossi Beilen said no decision was made, but Israel's armed forces radio carried reports that the detainees would be released gradually over several days.

Israel took the Lebanese prisoners as security risks during their withdrawal from southern Lebanon but has never charged them with crimes.

Berri and his top aides, Dickey reported, also said that assurances from Syrian Vice President Abdul Halim Khaddam late Saturday night advising him that a vaguely worded U.S. State Department statement that same night was adequate to meet the demand that there be no U.S. retaliation.

Berri and his aides said this last assurance was necessary to correct what Amal leaders contended was an almost disastrous misstep by President Reagan on Friday in publicly denouncing the hijackers -- who murdered one U.S. sailor on the plane -- and extremist kidnapers of other Americans just as the hostage negotiations had reached a crucial phase.

U.S. officials contend that Berri used the Reagan remarks as a pretext to cover up his inability, without more Syrian help, to gain control of the four hostages being held by the original hijackers.

But the hijackers wanted the last word, and two young men, wearing blue and salmon TWA pillow cases over their heads, dashed up to reporters at the Beirut airport, called America "the great Satan" and said, "We warn America not to play with fire, because we are sure to burn it."

The hooded hijackers said, "We got what we wanted" and claimed that the State Department statement was a submission to their demands. They said they had agreed to the deal, including a phased release of the prisoners held by Israel, after sorting things out "with our Syrian brothers" although Reagan's "reckless threat" had made them pull back Saturday.

The bizarre-looking convoy of vehicles that carried the freed hostages on the four-hour, 60-mile journey across Lebanon's battle-scarred landscape to Damascus was, in itself, a microcosm of the anarchy and chaos that in recent years had split that nation into little more than feuding fiefdoms with virtually no central government.

The jubilant Americans gathered in the Beirut schoolyard near the battered refugee camp of Burj al Barajinah, where bitter fighting between Amal and Palestinian forces had raged in recent weeks. A cheer went up when the four held separately finally showed up to join the 35 others.

They waved to reporters as they boarded 10 Red Cross station wagons and sedans at about 5:40 p.m. Beirut time yesterday (10:40 a.m. EDT). People watched from balconies. Several Amal gunmen shook hands with some of the hostages. The TWA pilot, Capt. John L. Testrake, was handed a bunch of pink flowers by a bearded Lebanese, and an Amal spokesman said he was sorry for the suffering and for the killing of Navy diver Stethem.

A truck with luggage from the plane joined the convoy, which was led by a Lebanese Army truck with antiaircraft guns mounted on it and flanked by other Soviet-built trucks with huge guns and other vehicles with red-bereted members of the Druze militia, machine-gun-toting members of the Amal militia and a car filled with Syrian intelligence officers.

The convoy first circled around the Shiite Moslem slums of west Beirut in what one Associated Press dispatch described as appearing akin to a victory parade. It skirted the Green Line, the no man's land between Moslem west Beirut and the Christian eastern sector.

The procession then rolled through Druze-controlled territory in the Chouf Mountains, scene of fierce battles when U.S. Marines were in Lebanon in 1983. At Sofar, about 12 miles east of Beirut and 19 miles from the Syrian border, Syrian troops took charge as they moved into the Bekaa Valley. This is home for most of the 30,000 Syrian troops in Lebanon, for several hundred Iranian Revolutionary Guards and for various Iran-influenced extremist groups including the Hezbollah, or "Party of God," which is believed to have carried out the original hijacking.

At the Syrian-Lebanese border, Syrian soldiers fired shots of celebration into the air. Amal soldiers gave the hostages copies of the Koran, the Islamic holy book, and three U.S. diplomats greeted the freed Americans and checked to make sure all 36 passengers and the three crewmen were aboard.

The 39 Americans were the last of the original 153 passengers and crew from TWA Flight 847, a Boeing 727, that had been hijacked by two Shiite extremists on a flight from Athens to Rome on June 14. The other passengers and crew were released in Algiers and Beirut as the plane was taken on an 8,500-mile odyssey by the grenade- and gun-wielding young terrorists.

On the second day of the hijacking, a group of about 10 passengers were taken off separately by the hijackers. This group, which included a number of U.S. Navy men aboard, eventually dwindled to four. One of the four, Richard Herzberg, said in Beirut today, "We knew we were their ace in the hole." As tensions between Berri's Amal militia and the hijackers linked to Hezbollah grew over the final terms for release, Herzberg said, the four hostages were driven away at high speed back into the Beirut slums Saturday night, when it looked like the deal might collapse.

One source close to the Amal leadership said a car bomb with 330 pounds of explosives was found Saturday night close to the location where the main group of hostages was being kept. The four who were kept alone had not been heard from until today.

Herzberg said he was in the insurance business. Jeffrey Ingalls, 24, also among the four, is a Navy diver who said he found out by reading news magazines brought by his captives that his buddy, Stethem of Waldorf, Md., had been killed by the hijackers. "But I didn't let on to them that it was one of my friends," he said at the Damascus press conference yesterday.

As the 39 returnees entered the Sheraton Hotel after their trip from Beirut, many were clean-shaven; others wore beards. But several looked tired and drawn with the strain of captivity compounded by the wearying uncertainty of the last 24 hours, Randal reported.

They managed, nevertheless, to joke and maintain a dignified calm at a news conference that took up about 15 minutes of their three-hour stay in Damascus before boarding a U.S. Air Force C141 for the four-hour flight to Frankfurt.

Conwell, the 39-year-old Texan who works for an oil company in the Persian Gulf state of Oman, paid tribute to the plane's crew and especially the German-born stewardess, Uli Derickson, who had been the subject of some confused reports about picking out passengers with Jewish-sounding names but who actually refused to do that. Rather, Conwell said, Derickson saved many lives and "stood between herself and the murderous hijackers."

Despite the calm and emotional distance from the initial events that the passengers displayed at the press conference yesterday, flashbacks to the first traumatic hours were apparent. Conwell talked of a "forest of fear" that had flooded through the plane when it all started.

Running throughout the remarks of Conwell, Testrake and some others who spoke was by now a familiar theme of the hostages: that their captivity taught them better to understand the complexities of the Middle East crisis that promoted the hijacking.

"We found things out about our fellow man on the other side of the world that we didn't know, and we found they were human beings. They have the same emotions, the same fears, the same expectations, the same hopes for their country as we all have. And in that sense," Testrake said, "we were able to empathize with them and we were led to have a deeper understanding of the problems they are facing."

Ingalls said, "It certainly has been a learning experience for me. In the United States, you see things through the media, and you kind of see the other side of the story being over here."

Robert Trautmann, another hostage held separately, said he was well treated and that his captors seemed to like Americans but not the American government.

Conwell, on behalf of the group, thanked Berri for his negotiating efforts in Beirut and Syrian President Assad and the Syrian people. Without this help, he said, "we would undoubtedly still be in Beirut with an uncertain future."

Berri said yesterday that two Frenchmen, kidnaped earlier in Beirut by extremists, also will be released in two days. But he said he has been unable to find out about seven other Americans who have been kidnaped during the past year by Shiite extremists groups but who have not been the subject of such intense global attention and publicity as those taken in the TWA hijacking.

The Reagan administration this week also demanded release of the seven, thus far to no avail.

As the plane bearing the former hostages landed, the sense of deja vu for the U.S. military personnel stationed here, was perhaps even stronger. Well-honed routines, first learned during the 1981 liberation of 52 fellow citzens from Iran, were refined in the evacuation of marines who survived the Oct. 23, 1983, bombing in Beirut.

The U.S. military hospital in nearby Wiesbaden, under the command of Col. Charles K. Maffet, mobilized doctors, nurses and psychologists to examine the physical and mental state of freed Americans. The hospital's third floor, named Freedom Hall after accommodating the Tehran hostages after their release, was outfitted again with telephones for the newly released hostages to make free calls home.

The Amelia Earhart base hotel next door was emptied of scheduled weekend occupants to make room for relatives of the released hostages. But many of them opted to accept TWA's offer of free lodging at plush hotels in Wiesbaden. The airline also agreed to fly the victims of the hijacking and their loved ones free of charge to destinations of their choice in the United States on Wednesday.

Outside the hospital, 46 American flags were hung to represent the 39 who were free and the seven who were left behind in Lebanon.

Initial preparations were set in motion a week ago but shifted into high gear Saturday morning once it became clear that release was imminent. A C141 military transport plane, fully equipped with medical facilities, was dispatched to Damascus. Leaves were canceled and officers and soldiers at Rhein-Main and Wiesbaden took up special emergency assignments.

As President Reagan's personal envoy, Bush flew in to the Rhein-Main base 30 minutes before the former hostages arrived in Frankfurt at 5:25 a.m. local time, 10 minutes early.

A group of about 20 dignitaries, including Frankfurt Mayor Holger Borner, U.S. ambassador-designate Richard Burt, Acting Ambassador William Wisner, and Sens. Charles McC. Mathias (R-Md.), Daniel Patrick Moynihan (D-N.Y.), Ted Stevens (R-Alaska) and Albert Gore (D-Tenn.) went out to stand beside the plane as Bush went aboard alone before anyone had gotten off.The senators are members of the Senate Arms Control Observers Group who were attending the Geneva arms talks before joining Bush in Paris, where they awaited confirmation of the hostages' release.

The first one off the plane was pilot Testrake, wearing his flight uniform and waving at the crowd. One by one, the freed Americans stepped off the plane, some jumping down the last several stairs in exuberance.

A cavalcade of buses then took the liberated Americans 25 miles from the airport to the Wiesbaden hospital, where they could bed down at the end of their odyssey.