Andreas Papandreou became Greece's first socialist prime minister in history today and moved rapidly to assert control over the nation's armed forces by warning them against any involvement in politics.

Clearly intent on stifling the kind of military revolt that kept his father from power in 1967, one of 10 military coups here since 1827, the newly installed premier met with Greece's defense chiefs.

He praised them for their professonalism under the outgoing defense minister, Evanghelos Aberoff, and warned them against meddling in politics. But he underlined his concern by keeping the sensitive defense portfolio for himself in the 38-member Cabinet of party loyalists, which President Constantine Karamanlis swore in with him at the presidential palace.

"Everyone in the armed forces is entitled as a Greek citizen to his own particular political beliefs," Papandreou said, "but it would be a great error for there to be any political activism within the armed forces."

Papandreou said that the military's "sole role" was the defense of the nation's "territorial integrity."

The poignancy of the encounter at the headquarters of the armed forces was lost on no one. The last time the Greek military intervened in politics was when right-wing colonels prevented former prime minister George Papandreou from forming a center-left government. The colonels' dictatorship, which first jailed and then exiled the son, Andreas, collapsed after Turkey invaded Cyprus in 1974.

Earlier in the day, meeting with the socialist Cabinet whose names were made public only shortly before dawn, Papandreou renewed his call for conciliation with all.

"We are a government of all the Greeks," Papandreou told his Cabinet after the one-block drive from the presidential palace to the Parliament building in a fleet of blue Mercedes limousines that eased through a crowd of several thousand undaunted by a light rain. The flag-waving and chanting supporters mobbed the ministers' cars, pounding on their windows in glee.

"The election battle has ended and from today the great task of building a new Greece begins," the 62-year-old Papandreou continued. He urged them to reward their voters' expectations of "personal morality and sincerity" because "we do not have a right to disappoint the people."

Papandreou's Cabinet offered few surprises. Virtually all his key appointees had been discussed in the Greek press since the premier's Pan-Hellenic Socialist Movement (Pasok) trounced the conservative New Democracy party of George Rallis in elections Sunday.

The latest tally of late returns computed today gave Pasok 172 seats in the 300-member National Assembly to 115 for the New Democracy. The only other party to gain seats was the pro-Moscow Communist Party of Greece, which got 13 deputies.

Papandreou's new Cabinet was made up exclusively of Pasok loyalists. Its average age of 53 makes it one of the youngest cabinets in recent Greek history.

Aside from Papandreou, who had served in his father's 1964 Cabinet after giving up U.S. citizenship and a post as head of the economics department of the University of California in Berkeley, none of the new ministers has been in government before.

Thus few Cabinet members are well known abroad, with the glaring exception of the culture and sciences minister, 55-year-old Melina Mercouri. She was made famous by her role as the tough whore-with-the-heart-of-gold in the film "Never On Sunday." A longtime Socialist, Mercouri's citizenship was stripped from her after she virulently denounced the colonels' regime.

The foreign ministry was taken over by 62-year-old Ioannis Haralambopoulos, a former military career officer who turned to politics and served as a parliamentary deputy in the 1960s as a member of George Papandreou's now-defunct Center Union Party. Under the dictatorship he was imprisoned for three years and exiled to an island in the Mediterranean Sea until 1974.

Haralambopoulos' experience in foreign affairs consists of a year's service in the European Parliament. The reading by Western diplomats is that the premier will probably dominate the application of his own nationalist positions that have included taking Greece out of the European Common Market and NATO as well as ending U.S. use of long-established bases in Greece.

Although these policies have made NATO governments uneasy to say the least, Papandreou mellowed the tone of his foreign-policy pronouncements in what many have interpreted as an appeasement to the armed forces near the end of his campaign. He has indicated that he will downplay foreign policy until spring, giving precedence instead to such internal concerns as reforming and decentralizing the government and nationalizing the key economic sectors of banking, ship-building, pharmaceuticals and the cement industry.

To spearhead the internal reforms, Papandreou has chosen a team of experts, seven of whom are not even in the Parliament, a departure from past governments that complies with his preelection promises of seeking outside talent for his government.

Orchestrating his internal reforms will be Minister of Economic Coordination Apostolos Lazaris, 61, an economist and university professor, Minister to the Presidency Agamemnon Koutsoyaryas, a 58-year-old lawyer and personal adviser, and several other socialist academics and technocrats.

The only minor surprise in the Cabinet was the exclusion of former foreign minister George Mavros, an old-guard liberal politician who threw in his lot with Pasok just before the election campaign to give the party a certain legitimacy with centrist middle-class voters. Many party leaders opposed Mavros' selection, however, because he was a latecomer.