In a stunning about-face, Greek Prime Minister Andreas Papandreou, a Socialist, today withdrew expected support for conservative President Constantine Karamanlis' reelection in what was seen as a de facto political alliance with the Communists.

The prime minister surprised even his own followers when, acting as its chairman, he told the Central Committee of the Pan Hellenic Socialist Movement (Pasok), the ruling party, that he was backing for president Christos Sartzetakis, 56, a respected supreme court judge who is not a member of Pasok.

Two decades ago, Sartzetakis won renown as the investigator of an apparent political killing in a case that inspired the movie "Z."

As Pasok supporters poured into Athens' streets, honking horns and waving green party flags, Karamanlis withdrew from the race.

Papandreou gave no convincing reasons for his last-minute dumping of Karamanlis, 77, only six days before parliament meets to elect a president for a five-year term.

Political analysts said Papandreou, 66, apparently made the switch because he felt he needed Communist support to win a new parliamentary mandate in elections due in October.

In recent months the Communists have called an increasing number of strikes in opposition to Papandreou's government, showing strength at shop-level. Last month, Papandreou visited the Soviet Union and although he was careful not to give the Soviets any propaganda advantage, his critics suggested his real purpose was to secure the Kremlin's support in persuading the Greek Communist Party to back him in elections.

From one end of the political spectrum to the other, Papandreou's move today was interpreted as a reversal of his public efforts in recent months to disarm American and other western critics and to woo centrist voters in the coming parliamentary elections.

Greece, strategically situated in the eastern Mediterranean, is a member of the North Atlantic Treaty Organization and the site of important U.S. military bases. Papandreou came to office on a platform of taking Greece out of NATO and removing the U.S. military bases, but neither has been carried out.

The State Department had no comment on Papandreou's move. On Thursday, Secretary of State George P. Shultz, in Senate testimony, said: "We have our differences with the Greek government. We want a better relationship with Greece, but the Greek government has to do its part as well."

Monteagle Stearns, U.S. ambassador to Greece, is expected in Washington for consultations Monday.

With the conservative, pro-western Karamanlis as president, Greeks and their foreign friends felt there was a prestigious counterweight to Papandreou's leftist rhetoric and action.

Addressing the Central Committee, Papandreou also argued that a new parliament should substantially reduce presidential powers and thus it would not be consistent with reelecting Karamanlis.

Papandreou is clearly counting on the 13 Communist members of parliament to join 165 Pasok members -- and whatever independents he can win over -- to elect Sartzetakis despite expected opposition from the New Democracy Party.

Barring unforeseen developments, Sartzetakis is virtually assured of election on the third round of voting 10 days after balloting starts on Friday.

Then only 181 votes -- three-fifths of the 300-seat parliament plus one -- will be required to ensure election, compared to the two-thirds majority needed to win in the first two rounds.

Karamanlis said he had not "asked anyone to reelect me" and already had "serious reservations" about running again.

He added that he had considered running only when politicians of the two main parties, "the leader of Pasok first and foremost, stated to me on their own initiative that they intended to propose my reelection because they considered it necessary to the smooth development of our political life and the nation's unity."

"I told them I would make my final decision after their final proposal," meaning formal endorsement by both Pasok and New Democracy, he said, "which I would assess on the basis of the general conditions prevailing in the country at the time."

"The matter for me has already been automatically resolved," he said.

The pro-Moscow Greek Communists, who regularly poll 11 percent of the vote, hailed Papandreou's decision as a "positive response" and a "serious event."

In a statement, the Communist Party insisted that the "particular personality" of any given presidential candidate was not the major issue, but rather a "general change in government policy."

The Communists for months have demanded a real share of power for the first time. As recently as this morning, the party paper Rizospastis shared the assumption that Pasok would back Karamanlis and denounced Papandreou for wanting to do so.

The party newspaper said Pasok Central Committee members were unhappy with backing Karamanlis but had been warned that any dissenters would be expelled.

As a young investigating magistrate, Sartzetakis had probed the 1961 death of leftist deputy Gregoris Lambrakis, who was run over by a truck driven by right-wing opponents during a political rally in Salonika. The case helped cost then-prime minister Karamanlis the 1963 elections and sent him into self-exile until 1974.

The candidacy of Sartzetakis poses a serious problem for New Democracy, the conservative party Karamanlis founded when he returned to run Greece after the military dictatorship collapsed in 1974.

New Democracy had formally endorsed Karmanlis' reelection, assuming Pasok would do likewise. To disavow him now would risk further alienating an electorate that might not understand why the party had changed its stand. George Papathanaspolos, the New Democracy spokesman, said "every level" of Pasok "including the highest level," meaning Papandreou, had promised to support Karamanlis' reelection.