The United States and Canada reached a historic free trade agreement late last night that will greatly reduce barriers to trade in a vast area stretching from the Arctic Circle to the Rio Grande.

The first word of the successful conclusion of high-level talks held here over the past two days came shortly before midnight, when Canadian Finance Minister Michael Wilson appeared at a window of the Treasury Building and gave a thumbs-up sign to reporters waiting outside.

"We got a deal," said a ranking U.S. trade official, adding that no details of the agreement were available. The White House said details will be released today.

The negotiators beat by minutes a midnight deadline required to win a speedy, amendment-free confirmation of the pact by Congress. Donald Anderson, clerk of the House of Representatives, said he received the needed presidential notification just before midnight.

The agreement -- a key element in the Reagan administration's trade policy -- was considered important for U.S.-Canadian relations, which have suffered for the past three years from a series of contentious trade disputes and were expected to worsen if no trade agreement is signed. If the talks had failed, as it appeared as recently as Thursday night, businessmen from both countries predicted a rise of protectionism in the United States and Canada that could have had an adverse effect on the fragile world economy.

The pact would ease restrictions to trade in merchandise, services and investment between the world's largest trading partners, which exchanged $150 billion in commerce in 1986. A key element for the United States was believed to be the phasing out of tariffs between the two countries. Canadian tariffs are about twice as high as U.S. duties.

The talks were stalled throughout a long day of negotiations on the thorny issue of meeting Canada's insistence on being exempt from U.S. unfair trade laws. That was the main demand of the government of Prime Minister Brian Mulroney, who had made a free trade agreement the cornerstone of his economic policy for Canada. But granting Canada the exemption it wanted ran into a storm of opposition from Congress.

While Reagan administration trade officials insisted yesterday they could not meet Canada's demands, it was unclear early this morning just how far the United States had moved on the issue in order to get the agreement. It was also unclear how many concessions the Mulroney government had made to U.S. demands on other trade issues, mostly related to Canada ending its barriers to U.S. imports and investment and its web of subsidies that gave Canadian products a competitive edge.

The United States had agreed to form a binational tribunal with binding powers, but favors giving it authority only to review decisions already made. Canada wanted the tribunal to decide trade complaints outside of regular procedures.

The final talks were conducted at a high political level, with Treasury Secretary James A. Baker III and U.S. Trade Representative Clayton K. Yeutter heading the American side and Wilson, Trade Minister Pat Carney and Derek Burney -- Mulroney's chief of staff -- in charge of the Canadians.

The midnight deadline was set by the Jan. 3 expiration date of a law that sets up a fast-track procedure for congressional approval of trade pacts without changes or delays.

The agreement was proposed 19 months ago by Mulroney, and the idea of eliminating trade barriers between the two countries won the strong support of President Reagan, who views it as an affirmation of his continued belief in free trade despite imposing more import restraints than any other modern president.

The success of the negotiations is critical to Mulroney, who predicted that free trade and access to the vast American market -- 10 times the size of Canada's -- would create 500,000 new jobs in that country.

But the idea of opening imports of American goods and ending Canadian barriers to investment -- especially in such sensitive sectors as broadcasting, films and publishing -- ignited nationalistic fires in Canada and created a backlash from unions, which feared they would lose jobs. This strong and vocal opposition has made it harder for Mulroney's negotiators to meet American concerns in the talks.

President Reagan also had a large stake in a successful agreement, which would create the largest free trade market in the world. The president often has cited these talks, along with a much smaller free trade agreement he signed with Israel in 1985, as evidence that his administration is not protectionist.

The talks also were seen as crucial to a key element of Reagan administration trade policy: the ongoing global trade talks to strengthen and expand the 95-nation compact that regulates world trade, the General Agreement on Tariffs and Trade.