DJIBOUTI (AP) _ Eleven Westerners arrived here today aboard a Soviet cargo ship and told a dramatic tale of being rescued from fighting in South Yemen by Soviet sailors.

''The Russians treated us magnificently,'' said Trevor Robinson, an Australian. ''They took risks for us.''

The five Frenchmen, three Australians, a Belgian, a Canadian and a Dane - all small boat sailors - said they were caught between in machine-gun and artillery fire as rival military units fought for control of the harbor at Aden, South Yemen's capital.

Some of the sailors, who said they were in Aden Monday when fighting broke out in an apparent coup attempt in the pro-Soviet country, told of gun-toting civilians, explosions, and panic. But they said they saw few signs of casualties.

The Westerners arrived in Djibouti, 130 miles across the Gulf of Aden from South Yemen, aboard the Pavel Antokolsky, a Soviet freighter.

They said they were transferred to the vessel after another Soviet merchant vessel, the Smolensk, picked them up in Aden and carried them to the safety of the open sea for transfer to the Pavel Antokolsky.

The 11 arrived in Aden last weekend aboard five small yachts, including Robinson's 30-foot sloop, which he had sailed from his home in Fremantle in west Australia.

Robinson said the Soviets braved machine-gun fire to take him, his crewmate, Dominique Roven of Canada, and the others aboard.

Bruce Cameron, 65, of Australia, said he was ashore when the trouble started. ''I was in a taxi and we came to a roadblock with civilians with machine guns,'' he said.

Within minutes, he said, he heard explosions and gunfire. The streets cleared and only armed civilians and navy personnel were in sight.

Cameron said he made it back to his boat, where he huddled trying to duck machine-gun and cannon fire that whizzed across the harbor.

The other Westerners transported by the Soviets were Pierre Brahy and his wife, Laurence; Eric Valtong, Frederic Riche and Michele Pongerard, all of France; Belgian Hugo Primeu; Sheryl Leth of Australia, and Stephen Leth (no relation) of Denmark.

Cameron said two of his crewmembers remained ashore in Aden, and that he fears they may have been arrested.

All 11 told of battles between the navy and air force on one side and the army on the other.

''It appeared the naval forces were the insurgents,'' said Robinson. But diplomatic sources in Sanaa, capital of neighboring North Yemen, said the navy was on the side of South Yemen's president, Ali Nasser Mohammed, while the army and air force were split.

The Westerners said torpedo boats slipped between huge cargo vessels and the smaller pleasure boats in the harbor while shooting at tanks and installations ashore.

Robinson said he believed the tanks and coastal emplacements initially withheld fire because of civilian traffic in the harbor.

But on Tuesday, the second day of the fighting, they opened up against the navy vessels. Robinson said several pleasure boats were hit in the crossfire, and that most of them suffered damage to their rigging.

The Westerners said they made their way to the Smolensk in dinghys. Most said they were afraid to try to sail out of the harbor because one pleasure boat that did, the British yacht Innocent Bystander, was fired on and hit.

The yacht did make it alongside a British cargo ship, the Pacific International, and the ship later radioed that the four adults and a child on the yacht had safely boarded.

Cameron said he considered swimming to the Soviet ship, about 300 yards away. But he said he abandoned the idea because of oil on the water, most of it from fuel lines ashore that had been broken during the fighting.

He said he decided to row to the freighter in his rubber dinghy and was halfway to the Smolensk when gunfire began to whizz about him.

''It was the longest 150 years in my life,'' said the white-bearded Australian.

Cameron said that after the fighting intensified Tuesday, the Soviet captain ordered his mooring lines cut and set sail as cannon shells fell around the ship.