By most accounts, the truce earlier this month between the United States and the European Community over American farm exports to Spain was concluded hours or even the day before it was announced simultaneously in Brussels and Washington.

But community spokesmen here contended that negotiations were continuing up until the moment the accord was made public by EC trade commissioner Willy de Clercq.

The United States went along with the community's ruse and kept the agreement secret, diplomatic sources said, so that de Clercq could present the accord to the EC member states before its terms were leaked and opponents had a chance to sabotage the deal.

The episode underlined a persistent problem for the 12-nation community: how to keep a united front in the face of growing challenges from the United States, its most important trading partner. The discord in the EC, which often is over how to retaliate to those challenges, also has limited efforts to counter a trade imbalance with Japan, another key commercial partner.

The EC nations most dependent on trade, such as West Germany and the Netherlands, have consistently refused to support trade tactics that hint of brinksmanship, preferring instead that all avenues to a negotiated solution be explored before hostilities begin.

The community "moderates" are helped by the unique structure of the EC, with its built-in tension between the executive commission, the bureaucracy in charge of conducting trade negotiations, and the council of ministers, which sets the broad negotiating guidelines and has the final say over any trade deal.

Commission officials complain that their attempts to act with a single voice in trade relations with the United States are often undermined by squabbling among the member states.

"There was lots of frustration in this house" in the past few months, one commission official said, as divisions arose over how tough a line to take in the dispute with the United States over American farm exports to Spain and Portugal. The exports were restricted earlier this year after the EC was enlarged to include the Iberian nations.

"The fears of some people were realized," the official said. "The Americans were laughing their heads off as the community tried to get its act together."

The divisions became apparent early in April, shortly after the United States and the EC made their opening threats of trade retaliation in the dispute. The commission took the unusual step of publishing a list of U.S. farm products that could be affected if Washington restricted EC agricultural exports.

West Germany, the Netherlands and Denmark, during a meeting of EC ambassadors in Brussels the next day, all objected to the explicit EC threat, which covered corn gluten feed, an important American export.

"We were afraid that if we had too strong a position, it would seriously damage the chances for negotiations," a trade expert at the West German Foreign Ministry said.

The West German official said the Reagan administration "made it clear" that if U.S. agricultural exports were restricted by the EC, the United States would retaliate against industrial products. For West Germany, this could mean restrictions on key exports like cars, chemicals and machinery.

"For our country, exports are more important than they are for the United States, Japan or any EC state," the official said.

A Dutch official said, "It has always been our policy to keep the lines open. We are pretty vulnerable, as a small trading nation, to retaliation.

"We are hesitant to give the commission a blank check in the trade field with the U.S. Others in the EC are not," the official said.

These "others" include France, a country whose exports are not insignificant, but which is also determined to resist what it sees as U.S. efforts to undermine EC agricultural policies. France is one of the chief beneficiaries of the community's $22 billion farm-support program.

France, the community's largest corn supplier, also stood to benefit from the new EC tariffs that effectively barred U.S. corn from Spain.

Throughout the EC enlargement conflict, France supported hard-line positions against the United States. But because of the cautious policy demanded by West Germany and other member states, the council of ministers didn't agree until mid-June to support publicly the commission's list of U.S. products for retaliation.

Even then, the ministers refused to give the commission powers to impose the restrictions automatically if the United States acted against EC products. They also instructed the commission to find a temporary settlement.

The restraints dismayed some commission officials.

"We're not trying to barge in and get Rambo-like powers," an official said. "We just want powers equivalent to those of the U.S. Everything the United States trade representative can do is automatic, within certain margins."

The community's need for consensus "does not allow the efficiency the Americans have," the official said.

Officials in Brussels, however, said the divisions were only one of the reasons why the EC ended up making the concessions that helped settle, at least temporarily, the enlargement dispute. And compromises were also necessary on the American side, they said.

Initially, "the commission may have overplayed its hand," one U.S. source said. "They thought they could ride it out and not sit down with us . . . but the council said, 'settle it.' "

"But it was not just a trade question," the source said. "It had a political dimension. There was a great deal of hand wringing over the recent deterioration in relations caused by Libya and arms control. The last thing that both sides needed was a trade war."