Prime Minister Margaret Thatcher said today she feels "deeply wounded by a friend" because of President Reagan's insistence on punishing a British firm for selling pipeline equipment to the Soviet Union. She said, "We will stick to that deal."

Thatcher's remarks were made in Glasgow, where turbines produced by John Brown Engineering Ltd. are being loaded on a Soviet freighter. They are her first comments on the pipeline crisis since Reagan ordered sanctions against European companies that defy his embargo on the shipment of American-licensed parts for the Soviet project.

Of all the European leaders, Thatcher appears to have the most natural rapport with Reagan on matters of domestic, economic and foreign policy. Thatcher's comments were designed to convey "a message," as she put it, to the president about how strongly she feels he is wrong.

Thatcher said that in a Washington meeting with Reagan in June, she had sought to explain that Britain could not accept his order that existing contracts for the pipeline be canceled. "I had the impression then that President Reagan didn't quite realize how serious it was," Thatcher told the British Broadcasting Corp. today.

She said that unemployment in Scotland -- now over 14 percent -- required that contracts for a company like John Brown be honored.

"I feel very strongly," she said, "that once you have got a deal you have got to keep it, short of war or something like the Falklands," a reference to Britain's conflict with Argentina in the South Atlantic.

Moreover, Thatcher said, the United States intended "to deliver wheat to the Soviet Union." Europe has protested the recently renewed U.S.-Soviet wheat sale agreement as inconsistent and unfair in light of Reagan's stand on the sale of European equipment for the pipeline. U.S. officials have insisted the two are different because, while the purchase of U.S. wheat costs the Soviets hard currency, the completed pipeline will earn them money.

Thatcher said that Britain must continue to be a "staunch friend" of the United States but "from that basis we must be pretty frank" about disagreement on the pipeline.

Meanwhile, as loading of turbines proceeded in Glasgow, diplomats continued to search for some way out of the conflict. Special U.S. Trade Representative William Brock is to meet here Thursday morning with Britain's Trade Minister Peter Rees and Deputy Foreign Minister Douglas Hurd. But officials said Brock was not expected to "negotiate" over the pipeline issue.

The focus of diplomatic efforts, sources said, is a meeting of "experts" who might devise some formula that would permit further shipment of the equipment while satisfying Reagan's determination to block the pipeline as much as possible.

Thatcher indicated that she has been in contact with Reagan over the problem and said that Britain and the United States would be "in touch fairly closely over the next few days" as the shipment is prepared to leave for the Soviet Union. Washington has indicated that the sanctions would be imposed against John Brown as soon as the ship leaves port.

Officials had little comment today on reports that the president has decided to limit sanctions against John Brown to its gas and oil operations, a lighter punishment than that given two French companies last week.

As a practical matter, unless the company can get parts from the United States, completion of its contract for 21 turbines will be difficult, company officials say, and the likelihood remains that some jobs will be lost.

Italy and West Germany are expected to begin shipment of parts for the pipeline in the next several days. Trade minister Rees said Britain might find it uncomfortable to be treated less harshly than the other Europeans. "We certainly see difficulties there would be in discriminating between various European companies," he said.

In her BBC interview, Thatcher said that had American policy all along been that no American parts or licenses could be used in the pipeline, Britain would have acted accordingly, but the retroactive nature of Reagan's order, which in June expanded restrictions originally announced following the declaration of martial law in Poland last December, was unacceptable. "Naturally," she added, "we feel deeply wounded by a friend."