Japan decided shortly before the filing deadline yesterday to boycott the Olympic Games in Moscow this summer.

The Japanese decision came as a welcome last minute boost to the Carter administration's boycott campaign following decisions by most of Washington's other Western allies to attend the Games. Among the latest U.S. friends to formally announce their participation in the Moscow Games were Spain, Australia and New Zealand.

As the deadline passed at midnight Moscow time (5 p.m. EST). it appeared that 50 countries had joined the American-led boycott to protest the Soviet invasion of Afghanistan, U.S. officials said only 71 nations will attend the Games, while the Soviets said 102 were expected.

The final figures will be announced by the International Olympic Committee at Lusanne, Switzerland, on Tuesday.

In Moscow, the official news agency Tass asserted last night that "the highly unseemly intrigues around the Olympics organized by some political circles have completely failed and they have been unable to bring about a demise of this festival of world sports."

The Japanese Olympic Committee's decision came in response to heavy pressure from the Tokyo government, which reportedly threatened to suspend athletes' passports unless they followed the boycott.

Commenting on the Japanese decision, a White House spokesman said, "Obviously we are pleased."

On numbers alone, the U.S.-led boycott campaign received less support than Carter might have wished. Yet U.S. officials said they expected that the impact would be noticeable. Lining up with the United States were such key sporting nations as West Germany, Canada, China, Japan, Norway and a number of Asian, African and Latin American countries.

But virtually all European countries will attend the Moscow Games, including such traditional U.S. friends and allies as Britain, France, Italy, Ireland, the Netherlands, Denmark and Portugal.

Two more countries expected to join the boycott, Jordan and Uganda, reversed themselves yesterday and announced that they would go to Moscow. Uganda's new military-backed government reversed an earlier decision made by the ousted president, Godfrey Binaisa.

Puerto Rico's Olympic Committee, by a 15-to-13 vote, allowed its member federations to decide individually whether to boycott the games. The island's basketball and track and field federations have voted to go to Moscow. The votes climaxed a fierce dispute involving Puerto Rico's internal controversy over its political relationship to the United States.

The Japanese committee voted, 29 to 13, to follow the Tokyo government's advice on the boycott. Apart from Japan and China, 16 other Asian nations will boycott the Games. They include Pakistan, Iran, Indonesia and Thailand.

Japanese sports officials said Lord Killanin, president of the International Olympic Committee, had told them he would "consider" Japan's request for a postponement of the filing deadline. Katsuji Shibata, chairman of the Japanese committee, said that despite the vote, "I'd like to leave room for Japan's participation."

West Germany's Olympic Committee president, Willie Daume, had hinted Friday that his group may reverse its earlier decision to boycott.

"We have until July 19 for possible revision," he said. The Moscow Games are scheduled to open on that day.

Most Westen governments have favored the boycott as a way of censuring Moscow for its invasion of Afghanistan, but Olympic committees in many countries have ignored government recommendations.