U.S. Secretary of Agriculture John R. Block signed a new long-term agreement on grain trade with the Soviet Union here today, calling it an "early building block in our efforts to build a stable relationship."

The five-year pact includes a basic compromise: it raises the minimum annual Soviet purchase of U.S. grain from 6 million to 9 million metric tons, but it obligates the United States not to apply export curbs. Such restrictions were imposed by the Carter administration in retaliation for the Soviet invasion of Afghanistan.

Block and Soviet Foreign Trade Minister Nikolai Patolichev signed the accord at a brief ceremony in the Foreign Ministry building. Block, accompanied by Mark Palmer, deputy assistant secretary of state, and other U.S. officials, subsequently joined the Soviets in drinking a champagne toast.

The last such occasion was held in 1979, when then-presidents Jimmy Carter and Leonid Brezhnev signed the SALT II agreement in Vienna. Relations have deteriorated sharply since that meeting, largely due to the Soviet invasion of Afghanistan in 1979. In 1980, Carter canceled contracts for 17 million tons of grain.

Apparently to avoid the recurrence of such actions, the treaty says that "the government of the United States shall not exercise any discretionary authority available to it under United States law to control exports of commodities purchased for supply to the Soviet Union."

At a press conference, Block appeared to go out of his way to reassure the Soviets that the Reagan administration had no intention to use grain sales as a foreign policy tool. "We want not only to be a good supplier but the best supplier for the Soviet Union," he asserted.

Asked whether the new agreement marked a shift in U.S. policy toward the Soviet Union, Block said that "we believe that a formalized trading relationship with the Soviet Union is in the best interest of the United States." He described Carter's embargo as a "failure" that only produced a decline in America's share of the Soviet grain market to 17 percent from 70 percent. "We forced them into the arms of other suppliers," he added.

The Soviets have given minimal publicity to the new agreement, signed in the midst of what promises to be an ample harvest. The official news agency Tass merely reported that a trade agreement was signed "covering some agricultural products."

Block called today's signing a "very, very important occasion" and suggested that it marked an end to a slump in trade during the past four years. Soviet officials refrained from comments.

Block also met with Gaidar Aliyev, a new member of the ruling Politburo.