Faced with the risk that the Common Market may run out of money early next year, the European Community's 10 heads of government struggled today to thrash out emergency reforms in the ways they collect and spend money for their joint programs.

British Prime Minister Margaret Thatcher, who came to the summit complaining that her country is forced to pay far more into community coffers than it receives, won a tentative refund of $675 million. But other European delegations stressed that the British rebate was contingent on the 10 leaders endorsing plans to revamp community finances before the meeting breaks up Sunday.

The European summits, held thrice yearly since 1975, were intended to deal with more visionary matters to provide greater impetus toward a united Europe. But invariably, they have tended to lapse into mundane squabbles over the monetary gains and losses of member countries.

The bitter budget dispute consigned topics of international politics, such as Poland, the Middle East and relations with the Soviet Union, to minor spots on the agenda as the leaders grappled with British demands for a huge refund before any other issues could be discussed.

The 10 European leaders intended to devote much more time to discussion of overtures that might induce Poland's military government to relax martial-law restrictions and encourage a better dialogue with the West.

The Europeans hope that following Pope John Paul II's trip through Poland, Gen. Wojciech Jaruzelski's government will feel confident enough to revive contacts with Western Europe. The 10 community leaders, according to one spokesman, hope to "open the door for new political and economic initiatives."

The community leaders intend to issue a declaration on Poland, the Middle East and the Madrid Conference on Security and Cooperation in Europe when the summit ends Sunday.

West German Chancellor Helmut Kohl, as host for the summit, sought to play a mediator's role by acknowledging the legitimacy of Thatcher's request. But he also insisted that future incorporation of Spain and Portugal into the community required immediate action to stave off the bankruptcy of costly programs such as farm subsidies.

During the arduous negotiations, the West Germans presented four different compromises linking the British refund to a package of other commitments, including target dates for the entry of Spain and Portugal, reform of the agriculture program and correcting lopsided contributions by member countries to the community's $24 billion budget.

West German sources admitted that Kohl was eager to score a substantial personal success by breaking deadlocks on a number of issues.

But the ancient nemesis to progress in the European Community--national interests--again bogged down negotiations and compelled Bonn to offer repeated revisions in the search for a successful formula.

France, Italy and the Benelux countries--Belgium, the Netherlands and Luxembourg--which profit greatly from the community's farm program, rejected any cuts in the subsidies that have created massive surpluses of wheat, milk and meat and forced a trade war with the United States to get rid of excess farm products.

The Common Market's agriculture policy now absorbs more than 60 percent of its budget and will become even more of a financial burden when the agrarian economies of Spain and Portugal are brought in.

The West Germans also suggested a small rise in sales taxes to cope with the growing budget needs. But that proved anathema to Thatcher, who rejects tax increases as a way to alleviate financial troubles.

French President Francois Mitterrand expressed reluctance about setting target dates for bringing Spain and Portugal into the community. According to his spokesman, Michel Vauzelle, France believes such pledges could turn out to be demoralizing if they could not be fulfilled.

West Germany staunchly has advocated the candidacy of the two Iberian countries, claiming that membership would solidify democracy there.

France, has balked at moving too quickly because it fears severe economic dislocations if two more Mediterranean nations join the community before Greece has been "digested" as the 10th member.