Canada has agreed to sell the Soviet Union a minimum of 25 million metric tons of grain over a five-year period, the government announced today.

The deal is the first such long-term agreement between the two countries in a decade. It secures for Canada a large chunk of the Soviet grain import market, which has fluctuated between 25 million and 30 million metric tons annually in recent years.

It comes at a time when the United States, having recently lifted the grain embargo it imposed after Soviet troops invaded Afghanistan, is hoping to negotiate a new grain deal of its own with the U.S.S.R. Under the current agreement, which expires in September, the Soviets buy between 6 million and 8 million metric tons of grain from the United States annually.

But trade sources say the Soviet Union has been seeking contracts with Canada and other grain-exporting countries to lessen dependence on U.S. sources and to improve the Soviet's bargaining position in the grain negotiations with American officials.

The Canada-U.S.S.R. deal provides for the sale of 4 million tons of wheat, barley and oats in the year ending July 31, 1982, with shipments increasing by 500,000 tons annually to reach 6 million tons by 1985.

A U.S. official here points out that this level of exports, consistent with Canadian sales to the Soviets in recent peak years, does not represent a major jump in Canada's share of the Soviet market.

But Canadian government spokesman Hazen Argue stressed that the contract called for minimum levels of shipments and said Soviet officials had expressed an interest in buying as much grain as possible from Canada over the life of the contract.

"In all probability, the quantities will exceed the minimum quantity," said Argue.

Today's deal probably will incite further controversy over wheat and other grain sales.