Although British Prime Minister Margaret Thatcher faces an election in less than two weeks, she scarcely needed the good publicity she received at the economic summit here to help assure victory.

Thatcher took a day and a half from campaigning to attend the summit as polls published today showed her far ahead of her closest rival, the Labor Party headed by left-winger Michael Foot, with the gap apparently widening.

Aides conceded that she could be hurt at home by discouraging summit news but said today that they think she did well.

On Saturday, British television viewers saw her riding in a carriage to be greeted with pomp and ceremony by President Reagan, then looking cheerful and composed with her six fellow leaders. Meanwhile, Foot was being seen on British television news having his jacket tugged by two dogs at an outdoor election rally.

British television has tried to report the summit straightforwardly by focusing on all of the participants. But with Thatcher often walking beside Reagan when the leaders enter and leave meetings, she looms in the forefront of the television coverage.

Thatcher wanted to attend the summit, sources said, because she saw it as a duty and a campaign advantage. Because this weekend is spring bank holiday in Britain, she might have received less coverage had she stayed home.

After it seemed that she and the other leaders would be unable to agree today on a statement of unity on defense, Thatcher was finally able to announce to the British press just before she left for home tonight that a "very significant, very fundamental" agreement has been reached.

She also had the satisfaction of being counted among the leaders whose economies were deemed on the way out of recession and whose anti-inflation policies were credited with success.

Appearing relaxed and smiling, she was described as "heartened" by private discussions Saturday with President Reagan, Japanese Prime Minister Yasuhiro Nakasone and West German Chancellor Helmut Kohl. All four were described as agreeing that their nations' economies are on the mend and that the world economy is moving out of recession.

With more than 3 million Britons out of work, the consensus here that Thatcher's government is moving out of recession is good news for the prime minister.

Thatcher broke Reagan's rule barring the heads of government from talking to the news media before the summit ends Monday. Apparently with U.S. approval, she held a news conference and gave television and radio interviews today for British reporters.

Thatcher was characteristically bullish about her economic policy, telling a questioner that her "perceptions of economic policy have been reinforced" by the summit. She pointed to the considerable economic improvement since the leaders last met--in Versailles a year ago--and stressed that her policies are responsible for the reduction in British inflation and beginning of recovery there.

She criticized strikers, blaming them for some British unemployment and stressed her concern about the jobless. Because of unemployment, she said, "We are so anxious to take steps to sustain and improve the recovery."

Thatcher criticized the United States for its large budget deficit, which she said is one factor keeping interest rates high.

Thatcher also strongly criticized the U.S. Export Administration legislation, now moving through Congress, saying that she is "very concerned" about extraterritorial rights over foreign-based companies that the act assumes. She said all of the Europeans expressed forceful opposition to the act.

Today's haste in producing a statement on defense and disarmament was "not in any way" seen as a special move to accommodate her early departure, she said. Thatcher demonstrated her familiarity with the economic summits--she has attended every one since 1979--by pointing out that foreign policy statements have often been issued on the first day of summits.

Thatcher's main concern here seemed to be in projecting a picture of western solidarity on economic, defense and foreign policies. She accuses her Labor opponents of irresponsibility in favoring unilateral disarmament and claims to have defused the disarmament issue in Britain.

The only hint of disunity with Reagan came with repeated references from Thatcher and her finance minister, Geoffrey Howe, to the problems created by high U.S. budget deficits.