Bettino Craxi took office today as Italy's first Socialist prime minister at the head of a five-party coalition in which the long-dominant Christian Democrats hold a majority in the Cabinet.

The 30-member Cabinet of Socialists, Christian Democrats, Republicans, Social Democrats and Liberals was sworn in by President Sandro Pertini and will face a vote of confidence next week in parliament, where it commands a majority.

Italy in a limited sense joins France, Spain and Greece in a Mediterranean turn to socialist rule. But the parties in those countries hold strong parliamentary majorities. In contrast, Italy's ranks third with the voters and second within the ruling coalition. No significant left-wing shift is expected.

Most observers here are reluctant to forecast the government's duration. The Christian Democrats' accommodation of Craxi can be explained by their need of his Socialists to make a legislative majority.

Yet the Socialist leader, admired for his political skill but considered abrasive and unpopular, could prove intractable if he feels that implementing unpopular economic and security policies might damage his party's status.

Craxi, at 49 the youngest prime minister since World War II, is considered a ruthless and talented party leader. He has consolidated the factions of the Socialists as he moved the still small party away from Marxism and into alignment with European social democracy. Craxi has served as vice president of the Socialist International.

Today's appointments include Christian Democratic ex-prime minister Arnaldo Forlani, who becomes deputy prime minister. Another Christian Democratic ex-prime minister, Giulio Andreotti, is foreign minister.

To beef up his Cabinet further, Craxi convinced two other party secretaries to take ministerial posts: Social Democratic leader Pietro Longo, who takes over the budget and planning ministry, and Republican leader Giovanni Spadolini, who becomes defense minister.

The apportionment of Cabinet posts represented the final and most delicate stage in the intricate political negotiations that led Craxi taking power. The Christian Democrats maintain a role commensurate with their standing as single largest political party.

Following sharp losses at the polls last June that brought their share of the vote to a low of 32.9 percent, the Christian Democrats agreed to cede the prime minister post to the Socialists, who made slight gains to win 11.4 percent and whose leader Craxi was pushing for the top job.

Of the 30 positions in the new Cabinet, 16, including the key deputy prime ministership and the ministries of foreign affairs, treasury, interior (police and public order) and justice went to the Christian Democrats.

Along with the prime ministership, the Socialists got five other posts, the most important of which is the Labor Ministry. The austerity- and Atlantic-minded Republicans received three, including finance and defense, the Social Democrats three, and the Liberals two.

The Christian Democrats, who have termed the coalition a pact "of iron" that should last for a full five-year legislature, also wrested from Craxi a commitment to consider gradually ending some of the local Socialist-Communist alliances that currently govern 32 provincial Italian capitals and to replace them with governments including some or all of the five government parties.

In addition, the Socialists agreed to changes in the new government's economic program and restated their commitment to "stand firmly by the decision made in 1979" to install 112 cruise missiles in Sicily in early 1984 if U.S.-Soviet negotiators fail to reach a relevant arms control accord.

The Communist Party--with 30 percent of the vote, it is Italy's second-largest--has pledged a vigorous antimissiles effort. It vows "determined opposition" to the new rule, in part because of the missiles issue.

The Communists, who over the last several months sought unsuccessfully to convince the Socialists to join them in a leftist "alternative" alliance, have accused Craxi of selling out to the Christian Democrats. The Communists also object to the new government's anti-inflationary economic program. A vigorous incomes policy is to keep increases in real wages below the inflation rate, currently running above 14 percent annually and scheduled to be forced below 10 percent by the end of 1984.

To further show commitment to new economic measures, the Socialists, who in the recent past have disagreed sharply with their allies over economic policy, have given the treasury, finance and budget posts to the Christian Democrats, Republicans and Social Democrats.

Republican Spadolini preceded Craxi as prime minister, until now Italy's sole non-Christian Democrat in the post since 1947. Because the small Republican Party made a strong showing in the June elections it is expected to play a key role within the new government.