Millions of Greeks voted nationwide today for new local governments in an election that was viewed here as a vote of confidence in Socialist Prime Minister Andreas Papandreou's one-year-old government.

With only partial returns in by midnight, the prime minister as well as his conservative and Communist rivals all claimed that the fragmentary results proved their respective parties were winning the approval of the voters.

Papandreou went on national television shortly after midnight to declare the election was a "crushing defeat" of the right that would be "completed" in runoff elections next Sunday for those who did not win absolute majorities today.

He based his claims on evidence that the local government lists supported by his Pan-Hellenic Socialist Movement had won some sweeping victories in small towns in the countryside that had been bastions of conservatism.

The prime minister's spokesman, Dimitris Maroudas, went even further when he told reporters that the government's analysis of the vote indicated that Papandreou's party stood to win 172 to 173 of the 276 mayoralities at stake around the country.

In his statement, the prime minister, admitted that in the major cities, where the vast majority of the nation's 9.5 million citizens live, "the fight continues," a seeming recognition that the vote in such places as Athens was too close to call.

Both the leader of the rightest New Democracy Party, Evanghelos Averoff, and Communist leader Leonides Florakis issued their own optimistic statements tonight saying the vote in the big cities showed their parties making significant gains that proved the country's voters were disenchanted with their first Socialist government.

In Athens, with about one-third of the Greek capital's precincts counted, incumbent Socialist Mayor Dimitrios Beys was trailing his New Democratic Party rival tonight 37.8 to 38.2 percent. The Communist-supported candidate had 18.5 percent of the vote, a full 6 percentage points above the Communists' citywide vote count in the 1981 elections.

Most of the country's 7.5 million voters were believed to have cast their mandatory ballots in their home districts by the time the polls closed.

Ostensibly the election was strictly a local affair: the selection of mayors and local governing councils for Greece's 6,400 villages and cities. As such, the issues on which it was fought were not Papandreou or the domestic and foreign policies of his government, but local issues such as traffic congestion, water pollution, bus services, health care and the state of local administration.

But the election was also taken by the government and its opponents as a test for Papandreou.

"Today's election is critical," editorialized the progovernment newspaper Ethnos. "No one doubts that in today's election the Greek people will reaffirm their confidence in the forces of change and display in the most vigorous and irrevocable manner their determination to fight with greater persistence and insistence to achieve the goals set by the government and condemn the rightist forces forever."

To do that, analysts here said, candidates backed by Papandreou's party had to win more than the 48 percent of the vote that the party took in last year's national elections. If they fall short, as most governing parties here have in the past in similar local elections, the government's opponents can say the electorate has begun to turn against Papandreou.

Candidates were not identified by party labels, but across the nation the candidates tended to fall into three main categories: those identified with Papandreou's party, those with the conservative New Democracy Party that Papandreou defeated last year, and those linked to the Communist Party, which after supporting Socialist candidates in 1981 broke with Papandreou to field its own list this year.

Papandreou's opposition this year is not coming merely from the traditional right that has so long criticized him as a dangerous Marxist, but also from the left that has found his policies during his first year in office disappointingly moderate.

Critics on the left say Papandreou, having been elected with a campaign slogan that promised radical foreign and domestic policy changes, has done little more than continue business as usual.

On foreign affairs, they point out, he talked of pulling Greece out of the European Community, taking the country out of NATO's military wing and kicking the United States out of the four military bases it has maintained on Greek soil since 1953.

Instead, Papandreou has made peace with the community, seeking renegotiation of Greek association with it. He has not brought up the issue of NATO beyond disputing air defense responsibilities over some Greek islands that NATO has tried to assign to the Turkish Air Force. And, he has given indications that he will accept at least some of the U.S. "facilities" in Greece for at least the short term, if the price is right when negotiations get under way at the end of the month.

The disastrous state of the Greek economy, and the continuing world recession, have dictated that Papandreou's promised "socialization" of the country be limited to such costless structural reforms as decriminalization of adultery, lowering the voting age to 18, reform of the trade union statutes, attacking an electoral law that encouraged patronage and legalizing civil marriage.

Despite all the grousing about the state of the economy around Greece, Papandreou insists that slight improvements have been made over the disastrously weak economy he inherited from the New Democratic Party government of George Rallis last Oct. 18.

In an interview this weekend he pointed out that when he came into office last year, Greece's public deficit was running at $2.5 billion -- or 17 percent of the Greek national product -- economic growth was below zero and inflation had been hovering at the 25 percent mark since 1979.

In his first year in office, Papandreou said, he had brought the public deficit down to $2 billion, or 14 percent of the national product, brought the growth rate up to 1.5 percent and reduced inflation to between 21 and 22 percent.

"It is not something to write home about," the prime minister said sadly, "but it is still something positive . . . .Considering what is happening in the world and Europe in particular, I think we are doing better than expected."