The International Whaling Commission voted today to declare a worldwide moratorium on the commercial hunting of all whales starting in 1986.

The vote, 25 to 7 with 5 nations abstaining, came over the protest of most countries that maintain whaling industries. It was a victory for conservationists--who have advocated such a ban for years to stem the declining numbers of whales. But opposition to the moratorium from such important whaling nations as Japan and the Soviet Union could mean that the commission will now lose the members it is trying to restrain.

Japan's delegate, Kuneo Yonezawa, said the decision was "clearly in violation" of the 1946 International Whaling Convention. He said the decision on Japan's possible response would be taken by the Cabinet.

The delay in the start of the ban was designed to ease the transition for whalers. In addition, the countries agreed to review the ban in 1990 to see whether any whaling might then resume. But these concessions may not be enough to prevent opponents from challenging the ban.

Under rules of the organization, which was created under the 1946 convention to regulate international whaling, any country can formally object to restrictions placed on its activities and withdraw--whereupon the commission would have no further power to enforce its jurisdiction. It was not clear tonight how many of the whaling nations will officially object. They have 90 days to make their views known.

The main whaling countries are Japan, the Soviet Union, Norway, Iceland, Brazil, Peru, South Korea and Spain. Of these, only Spain voted to support the ban, complying with a vote some months ago by its parliament. The others voted no.

Chile, China, the Philippines, South Africa and Switzerland abstained, and Dominica and Jamaica were absent.

Conservationists said the U.S. attitude could be critical in determining if Japan does file an objection to the ban or leaves the organization. The Reagan administration has been a backer of the moratorium, and officials have been reported as saying they would consider sanctions against Japanese fishing in U.S. waters if the ban is not respected.

At the decisive meeting, the U.S. Representative, John V. Byrne of the Commerce Department's National Oceanic and Atmospheric Administration, made no statement while voting in favor of the action, according to American conservationists in Brighton, the British seaside resort where the session is taking place. An alternate U.S. delegate, Thomas Garrett, greeted the vote as a victory for the United States.

Over the past decade, as the stocks of whales seemed to be falling sharply, the commission voted a number of measures, such as an end to factory ships, an Indian Ocean sanctuary, restraints on killing methods and lower quotas for certain species. The catch set by the commission declined to 14,000 last year from 42,000 a decade earlier. But the organization has failed in all previous efforts to get an outright ban.

Membership of the group has risen from 17 members in 1978 to 38, reflecting primarily the save-the-whale efforts of conservationists. With the important addition of Spain, opponents of whaling had the three-quarters majority required to achieve the moratorium. At the same time, the whaling countries complained of an undue voice for countries with no direct interest in the outcome.

For Japan, the issue of whaling is an emotional one. Whales have long been a staple food product. According to a report in the Financial Times of London quoting Japanese officials, a ban on whaling would mean a commercial loss of more than $50 million in primary whale products and another $150 million in such secondary products as oil extracts, fertilizers, hormone pills and cosmetics.

Potential job loss was put at about 14,500 in the whaling industry and related trade. As a result of whaling commission restrictions in the past 20 years, Japanese whaling has decreased by about 20 percent while demand has remained stable, pushing up prices, the Financial Times reported. Other publications say Japanese have become less interested in whales.

But those who follow the issue, including many conservationists, recognize that Japan resents other countries directing it to cease an activity that has been a part of its culture for hundreds of years. In urging restraint at the start of the conference, Joanna Gordon, a British conservationist, wrote that if Japan left, the commission "would be disastrously weakened, just as it is becoming a real force for conservation."

The arguments of those who favored the ban were that the numbers of whales had dropped so substantially that stronger action was necessary. Their hope is that the whaling nations will decide not to disregard the overwhelming majority vote of an international organization and carry on whaling.

Britain's agriculture minister, Aick Buchannan-Smith commented tonight that the vote "should lift the threat of extinction from some important stocks of whales. I hope that this decision will be implemented in the normal way."