The Defense Department, under pressure from a federal judge who accused it of acting abritrarily and capriciously, awarded veterans status yesterday to thousands of Americans who served as merchant seaman during World War II.

The action, in the form of an order from Air Force Secretary Edward E. Aldridge Jr., is expected to end an eight-year struggle over the efforts of three men who served on U.S.-flagged merchant ships during the war.

They sought the same government benefits accorded sailors and others in service during the war.

"The most immediate and most significant benefit is the honor of recognition," said Joan Z. McAvoy of the Washington law firm of Proskauer, Rose, Goetz & Medelson, which handled the case for the three men and the AFL-CIO, which supported them.

McAvoy said the ruling will enable surviving merchant seamen to receive the same benefits as other World War II veterans, including medical care, loans and pensions through the Veterans Administration.

"Well, I'll tell you that I am really grateful after 40 years," said Stanley Willner, 69, of Virginia Beach, one of the three merchant seamen.

"I'm just so sorry that so many of my friends who I served with aren't still around," said Willner, whose ship was sunk by a German raider in the Indian Ocean in 1942. As a prisoner of war, he later was forced to work on the bridge over the River Kwai.

McAvoy said last night that government officials estimated several years ago that perhaps as many as 90,000 of the 250,000 merchant seaman who served during the war are still alive. She said she doubts that the figure is still accurate.

The case of the three seamen was filed in U.S. District Court here and supported by the AFL-CIO, whose maritime unions represented several civilians employed on the ships.

It was opposed by several veterans groups, including the American Legion, which had lobbied the Defense Department to rule against the seamen.

The Air Force, which had been granted responsibility for determining the status of such cases, had opposed the action, saying the seamen had limited military training and had not sworn to assume the same obligations as had members of the armed services.

Willner and his lawyers disputed that. "I think we saw more service than 90 percent of those in the American Legion," he said last night. "Most of them stayed in the States."

In October, U.S. District Court Judge Louis F. Oberdorfer ruled against the service, saying its position was "not supported by substantial evidence."

He directed Aldridge to reconsider the case.

"This is just, and it is justice long overdue," said C.E. Gene DeFries, president of the National Marine Engineers Beneficial Association, a labor group that has championed the cause of the merchant seamen since the end of the war.

"These American merchant marines were men at war, plain and simple," he said in a statement. "They were not cardboard Rambos, talking tough on defense and nowhere to be found at the first whiff of gunpowder."

The decision did not give McAvoy everything she had requested. Aldridge granted veterans status to any person who served on a U.S.-flagged, oceangoing merchant ship between Dec. 7, 1941, and Aug. 15, 1945, the period between the attack on Pearl Harbor and the Japanese surrender.

McAvoy had requested that anyone who served until Dec. 31, 1945, be covered, the same cutoff for World War II service used by the VA.

Willner, who is bedridden with a back injury and had to be nursed to health by his family after the war, said he is not planning a celebration. "I'll be all right," he said in a weak voice. "I'm a survivor."