Italian Premier Giovanni Spadolini was forced to resign today following the defection of the Socialists from his five-party government coalition.

The 28-member Cabinet convened briefly this morning to announce its resignation. Later in the day, Spadolini met with Italian President Sandro Pertini to make his stepping-down official. As leader of the tiny Republican Party, Spadolini was Italy's first head of government since l945 not to be a member of the Christian Democratic Party.

The 85-year-old president, who in recent months has helped to avert several incipient political crises, asked Spadolini to stay on in a caretaker capacity. Cutting short a vacation in the Italian Alps to return to the captial, Pertini will begin consultations on Monday for the formation of a new government.

The Cabinet's seven Socialists resigned Thursday after a tax reform bill they supported was defeated in parliament, causing the collapse of Italy's 41st government since the end of World War II and throwing a vacationing Italy into a political crisis. Spadolini's 13-month-old government was relatively long-lasting compared to others of the postwar period.

If a new coalition formula is not found, the crisis could pave the way for early general elections this fall, more than 1 1/2 years before scheduled.

"I don't have a magic wand," Pertini told reporters. But he said he would do his best to keep the country from going to the polls early.

Most of Italy's political parties, including the dominant Christian Democrats and the opposition Communists, have said they are opposed to early elections. A dissolution of parliament would be likely to nullify a far-ranging emergency austerity package that the Spadolini government has just completed in an attempt to stem a massive budget deficit.

The Socialists, however, the country's third-largest party with about 10 percent of the national vote, are convinced that they could improve their standing significantly, and political analysts here believe the party has been looking for an occasion to provoke a new election. Given the unspoken rule that the Communists cannot be brought into a government, the Socialists are in a commanding position in the formation of any government.

Wednesday, a bill to prevent tax evasion, presented by Socialist Finance Minister Rino Formica, was defeated when a group of 30 Christian Democratic backbenchers bolted party ranks and voted with the opposition. After the surprise defeat, the seven Socialists in the Cabinet said Thursday that they would resign.

The bill levied taxes on petroleum product refiners and set penalties for tax-evading merchants and professionals. Charging that the coalition was not living up to its promises of "economic severity with justice" and that the country had become "ungovernable," Socialist leader Bettino Craxi endorsed the walkout Friday.

The crisis was unexpected, because the Christian Democrats and Socialists recently patched up a dispute over wage indexation policies and had agreed to the emergency economic program.

The Socialists rejoined an alliance with the Christian Democrats in April 1980, but the two parties have engaged in constant squabbling that has risked hampering government action. Spadolini, with his small political base, had little effective power and owed his appointment to a stalemate between the Socialists and Christian Democrats.