The fate of the passengers aboard TWA Flight 847 turned in the midnight instant when one of the two hijackers pressed a pearl-handled pistol against the temple of young Navy diver Robert Dean Stethem, of Waldorf, Md., and shot him dead, an act the others on board say persuaded the reluctant Amal militia -- the "good Shiites" -- to get involved.

This story of the 17-day ordeal comes from those who lived it -- from hostages freed yesterday and from others released earlier who held back certain details of the flight until they no longer had to fear reprisals against the remaining captives.

The drama began in the summer heat and confusion of Athens airport on June 14. Flight 847, flown by 30-year TWA veteran John L. Testrake, took off just after 10 a.m., about an hour late.

Evelyn Balt, 70, a retired deputy tax assessor from Oswego, Ill., was in Seat 25F, near the rear of the plane. About 10 minutes after the plane became airborne, when the no-smoking light went out, her husband, Stanley, lit a cigarette. "Just then, there was confusion of some sort behind us," she recalled. "I saw passengers putting their hands up." Her husband told her it was a hijacking. "You gotta be kidding," she replied.

That triggered an 8,500-mile odyssey as the captive Boeing 727 aircraft shuttled between Beirut and Algiers. Under orders from the two hijackers, the passengers were forced to spend as long as seven hours with their hands on their heads, heads between their knees. From that position, one woman could recognize no more than her mother's shoes when the older woman was allowed to leave the plane at one stop.

The hostages were forced to sit still while the hijackers beat at least two young U.S. servicemen and shot one of them, Stethem, to death. They were robbed of their jewelry, cameras and money. One passenger estimated the terrorists' take at about $150,000.

Some hostages went as long as 24 hours without being allowed to use the bathroom. Some were slapped or hit with gun butts when they tried to move. Some saw stacks of explosives and feared that the plane had been wired to blow up.

But there were also flashes of kindness from some of their captors and even a joke that made the rounds among the passengers: TWA "frequent fliers" would get double mileage for the Beirut-to-Algiers leg.

The most frightening moments occurred during the first hours after the hijacking, while the passengers were in the hands of the two classily dressed men in Palm Beach suits and Italian shoes who had arrived for the flight at the last minute.

The passengers have drawn a sharp contrast between this violent and moody pair and the more controlled, professional Amal militiamen who boarded the plane during its second stop in Beirut and took custody of most of the hostages.

The first two hijackers, identified by a confederate as Ahmed Kharbeia and Ali Yunes, both 20, had planned to "hopscotch throughout the Middle East and in each place leave a body of at least one American on the tarmac," hostage Allyn B. Conwell said in an interview televised at a seaside restaurant in Beirut last Thursday. Terrorists Take Over

As the plane left Athens, the terrorists left their seats and sped toward the cockpit -- "like they were running the 100-meter dash," recalled Jose Delgado, 64, a retired barber from Escondido, Calif. He sat in the plane's rear, ahead of the hijackers' seats. "One was really well-dressed. The other one looked like an everyday kid. Very clean. You couldn't spot 'em."

One of the two hijackers, about medium height, carried a silver automatic pistol with a pearl handle. Both he and his taller companion had hand grenades.

As the pair reached the cockpit, one of them chopped the flight's purser, Uli Derickson, across the chest with his hand and pushed her up against the cockpit door while the other put his pistol to her head. Like the hijackers, the blonde Derickson, a citizen of West Germany, could speak German and was able to serve as a translator.

Several of the hostages have proclaimed Derickson "a real hero" for her conduct during the flight.

The cockpit door was jammed shut. When the hijackers finally forced it open, one of them hit flight engineer Benjamin C. Zimmermann with the gun butt. They pulled the pin on one of their hand grenades, according to Derickson. "They dropped the pin and made me pick it up and put it in their mouth."

The hijackers cleared out the first-class section for their command post, herding the dozen first-class passengers back into the coach section. They ordered everyone to put their hands on their heads and bend forward. "Down! Down! Down!" they yelled, slapping or hitting passengers on the head as they passed. They told the passengers not to talk to each other, and hit or shouted at them if they did. They shuffled the passengers around "like a game of musical chairs," as Delgado put it, so that only women were in aisle seats and families were separated.

Soon, the passengers heard the voice of a flight attendant on the public address system, saying, "We are cooperating with these two gentlemen . . . . We are flying to Beirut." Noting that the hijackers were Shiite Moslems, Derickson told the passengers that the hijackers had a sack full of grenades and were threatening to blow up the plane.

During the nearly two-hour flight to Beirut, the hijackers sent a flight attendant up the aisle to collect passports and military papers. Derickson recalled that there were four men with military IDs and one with an official passport. They were all ordered into the first-class command post.

Delgado recalls seeing Stethem, seated just ahead of him, pull out his military ID and "one of the hijackers shouted, 'Army!' and Stethem said, 'No, Navy.' " After a few moments, the hijacker pulled Stethem out of his seat. "That's the last I saw of him," Delgado said.

"They went up and down the aisles hitting people and asking them, 'Who are you!' What do you do!' " Delgado added. "I said, 'I'm just an old barber.' "

As the plane approached Beirut, the control tower denied it permission to land. Pilot Testrake, whose cool voice was to become the human punctuation for the tensest moments of drama on the plane, said, "Beirut, the hijacker has pulled the pin on his hand grenade. He will land at Beirut. He is desperate." The tower gave in with apparent reluctance. During this hour-and-a-half stop, the hijackers released, by way of the plane's emergency chutes, the oldest and most "feeble-looking" passengers and mothers with children. Evelyn Balt was released here, "one of four women who got off the plane with their purses," she said.

When the tower balked at a request that the plane be refueled, Testrake announced by radio, "They are beating the passengers . . . . We want the fuel now. Immediately!"

The hijackers had started beating Stethem, a 23-year-old Navy frogman who was on his way home from a repair job on a Navy sewage plant in Greece.

The hijackers had pulled him from his seat and tied his hands, according to Ruth Henderson, 16, of Australia. "I watched as they kicked him in the head," she said. "They kicked him in the face and kneecaps and kept kicking him until they had broken all his ribs. Then they tried to knock him out with the butt of a pistol. They kept hitting him over the head, but he was very strong and they couldn't knock him out." During this stop, the flight attendants served orange drink and stale bread.

Finally refueled, the plane, full of grim and silent passengers forced into bent-over positions, took off for Algiers, 1,900 miles away, where others were released.

It wasn't until arrival in Algiers that the hijackers allowed their captives bathroom privileges. "I have better kidneys than I thought," said Ed Liebst of Lake in the Hills, Ill., who had gone 24 hours without using the bathroom.

Facing nightfall and mounting despair, the remaining captives were flown back to Beirut. Just after 2 a.m., as the plane landed at Beirut, Derickson warned the passengers, "Ladies and gentlemen, put your heads down, shut your eyes. You will hear some noises. Do not look up. Your fate depends on it. Everyone must cooperate."

The hijackers, in first class, closed the curtains between them and the passengers in coach. "He's about to shoot a passenger," Testrake radioed the tower. After a pause, the pilot said, "He just killed a passenger."

The hijacker had pressed the muzzle of his pistol to Stethem's temple and pulled the trigger. "You see," came the voice of one of the hijackers over the radio to the tower. "You now believe. There will be another within five minutes."

Stethem's battered body was dumped on the tarmac, where it was retrieved by a Red Cross ambulance. Some captives heard the muffled shot. Others were not aware of the murder until later when they were in Beirut with access to radios and newspapers.

Testrake said yesterday as he left Beirut that Stethem was shot as part of a dispute between the Amal militia and the hijackers. "They Amal did not want to be involved in this. That's why the young Navy man was shot and killed, because they at first refused to become involved with the hijackers; they didn't appear . . . . After that, they did become involved." But at least one hostage account indicated that the hijackers killed Stethem because they thought he was a Marine.

Soon after the shooting, about a dozen Shiite Moslems in battle fatigues, weighed down with ammunition belts and an assortment of machine guns, pistols, knives and other weapons, stormed onto the plane.

At about the same time, between six and 10 passengers were herded off the plane by the radical Hezbollah faction, which is sympathetic to Iran, and vanished into the Beirut night. The hostage group reportedly was made up of men carrying U.S. military or diplomatic identification or with "Jewish-sounding" names. Changing of the Guards

With the arrival of the Amal, the tension lessened. Passengers were allowed to sit up normally and try to get some sleep. One man in the Amal group, wearing jeans and a T-shirt, gave little speeches in good English about the virtues of the Shiite faith and the decadence of American society. Shortly before 6 a.m., the plane left Beirut, bound once again for Algiers.

Passengers were hauled one by one up to first class and robbed of their jewelry, money and other belongings. The Shiites did not keep credit cards, noted passenger Robert Peel Sr. They tossed cards, drivers' licenses and so on into the aisle so that "it was slippery when people walked down it to go to the john." Less than 24 hours after he was released and in Paris, Peel said, American Express called to ask if he wanted a new credit card.

Some of the Shiites marched up and down the aisle delivering anti-American harangues; one kept shouting, "My whole family murdered by New Jersey!" Peel did not understand until someone explained that the battleship USS New Jersey had shelled Lebanon in the fall of 1983.

In Algiers, late in the day, after discussions with Greek officials and the freeing of a Shiite accomplice captured in Athens, the hijackers said they would free all Greek nationals and remaining women.

The plane's air conditioning had been shut down, and passenger John Mazurowski remembers how his daughter, Melissa, 19, "started shaking from the heat, exhaustion and fear and I began insisting to the reasonable ones that she had to get to a doctor." Finally one of the Shiites let her go to the rear door of the plane for air. While she lay on the floor, "one found a bag of some sort that he put under her head as a pillow and found some napkins and began wiping off her forehead," Mazurowski said.

"Another who had a machine gun in his lap sat in a seat next to her and sang to her. Then a supply truck arrived with food and drinks and the good Shiite who was tending her took some ice to cool her head."

When they released her soon afterward, her father pushed his way off the plane with her and, with a nod, the Shiite let him go. "He leaned down and said to me through the window, 'See, we are good to you. Tell the people in America that we are good.' "

Late that Saturday, the hijackers released nearly 60 more people, including most of the women left on the plane and most non-American males. In the predawn hours of Sunday, they released another three to a representative of the International Committee of the Red Cross, Delgado and Liebst among them.

At 9 a.m. Sunday, the plane carrying about 30 passengers and three crew members took off from Algiers and headed for its third and final landing in Beirut.

Later that day, in Beirut, the hijackers handed out a letter signed by 30 passengers. It beseeched President Reagan not to use military force and to persuade Israel to free more than 700 Lebanese prisoners, mostly Shiites, as the hijackers demanded. Group Disbanded in Beirut

On Monday, the plight of the hostages changed dramatically. After nearly four days on board, they were taken off the plane and scattered to Shiite "safe houses" throughout Beirut. The three crew members remained under guard aboard the jumbo jet. By this time, the original two hijackers had vanished and were not seen again.

The next day, Demis Roussos, a famous Greek singer, was released with two other passengers. He said his captors had served him a birthday cake with tea and asked him to serenade them.

Then the remaining hostages began to surface in a series of often-surrealistic interviews staged by their captors and aimed at U.S. television viewers, after which they were led at gunpoint back to undisclosed locations. They sat across from American camera crews and reporters and expressed increasing sympathy for the cause of their captors, responding negatively when asked if they were being brainwashed or coerced.

In the interview at the seaside restaurant, Conwell said at one point, "My compliments to the restaurant that our hosts have brought us to today . . . . Generally we have airplane-type food." At the end, he and other hostages were seen on television shaking hands and smiling with their captors and the restaurant proprietors.

There were times when "we've been nervous so we got anxious for cigarettes; there were a few anxious moments when people didn't have toilet paper and things like this but in all, we knew and expressed our sincere appreciation that we had the basic essentials of life," Conwell said.

At first, he said, some hostages held separately by Hezbollah were in substandard housing -- "in a room without windows and concrete floors with small thin mattresses to sleep on, no radio, no television, no newspapers." But he called this to the attention of Amal, which, he said, upgraded everyone "so to speak, to at least tourist class." In captivity, most were fed sandwiches, dry bread, boiled eggs, cheese, rice and chicken dishes and occasionally a little fruit, according to freed hostage James Dell Palmer, who spent 13 days in captivity. There was virtually nothing to do, he said. "You sleep a lot, you eat, you drink coffee, you read newspapers, listen to the radio, pray and talk to the other hostages."

Keeping track of time was so important to the captives, he said, that he left with them the one possession he had kept hidden from the hijackers on the plane when they robbed the passengers: his watch.

Robert Trautmann Jr. of Laredo, Tex., one of those held separately by Hezbollah, said yesterday in Damascus that he and three others had been "put in a room. We were given foam mattresses and ample food. The people were always courteous to us . . . and tried to help us whenever we needed help, especially with providing us with medication, toiletries and the like." He said none of the group was physically or psychologically abused.

Jeffrey Ingalls, one of five Navy divers who had been members of a Norfolk-based SeaBees team that had included Stethem, said in Damascus yesterday that he never brought up the question of Stethem's murder with his captors. Asked by a newsman at a packed news conference whether his story might change, he said cautiously, "I really can't say . . . . It's definitely been a learning experience for me."

Staff writers James R. Dickenson, Kevin Klose and T.R. Reid contributed to this report.