As high-adventure escapes go, it had all the proper ingredients: a merchant vessel trapped in a flash war in the Middle East, three stranded young women, a daring British journalist secretly negotiating with one of the warring governments, and a dash for freedom amid the crackle of gunfire.

It happened last night in the Shatt-al-Arab waterway when 23 crewmen and passengers of a British freighter trapped in Iranian waters since the outbreak of the Gulf war slipped away under the cover of darkness and fled to Iraqi lines.

The ship, whose name is being withheld because there are still 13 crewmen aboard who fear Iranian reprisals, set sail Aug. 2 from Philadelphia, with cargo destined for North American ports, Brazil and the Iranian port of Khorramshahr.

A month later, it became trapped in the Shatt-al-Arab, between Khorramshahr and Abadan, when fighting broke out between Iraq and Iran in a territorial dispute over the waterway. Scores of other ships became similarly trapped, and some of their crews escaped and swam to safety when Iranian forces opened fire on them.

One of the ship's passengers, Teresa Hancock, 21, one of three British wives aboard the ship, said that for the first few weeks of the war, the passengers and crew were confined to quarters because of the constant small-arms and artillery fire, from both sides of the Shatt-al-Arab. c

"We learned just about every card game there is. It was quite boring," said Hancock.

The ship's owners, unable to persuade the British government to negotiate the release of stranded passengers and crew, contacted John Snow, a correspondent for London's Independent Television Network, who began unofficial discussions with the Iraqis for a plan to free the persons on board.

The ship's captain had been unwilling to risk an escape attempt earlier, according to crew members, because the vessel was in the middle of crossfire from the Iraqi and Iranian sides of the front.

With the help the captain of a Norwegian freighter, Snow devised a series of code names for various nights that the escape could take place, with last night being designated as "pear," to deceive any monitoring Iranians.

When the tide was right, and the sky black on a moonless night, the captain slowly let his vessel drift near the Iraqi side of the Shatt-al-Arab toward a waiting party of Iraqi special forces commandos.

Snow, donning a skin-diving suit and smearing his face mud, waded toward the ship dragging rubber dinghies, then climbed up a rope ladder to alert the passengers and crew.

He said he first encountered a Filipino crewman on deck, and that the crewman looked startled, and then disappeared below. But the crewmen organized themselves and lowered a lifeboat for the escape to the Iraqi side of the waterway.

"There was a terrible banging when the lowered the boat. I thought sure they [the Iranians] were going to spot us," Snow said.

Hancock said the escape went off without a hitch.

"I was a bit dubious at first, but it went rather smoothly," he said, adding that while they were headed ashore, Iraqi and Iranian troops exchanged fire across the waterway.

The crew and passengers left for Kuwait today, in transit to London, leaving behind the ship's captain and a skeleton crew of 12 men.