n another step toward an historic political realignment in Britain, the small Liberal Party formally decided today to join the upstart Social Democratic Party in an alliance to contest the next national election as a centrist alternative to the ruling Conservative and opposition Labor parties.

By the vote of all but 112 of 1,700 delegates at the annual party conference, the Liberals agreed to divide up the country's parliamentary constituencies with the Social Democrats to maximize their strengths in an all-out effort to dislodge the two major parties.

The opportunity presented them by the increasing polarization of the Conservatives and Labor was illustrated by three other political developments here this week: a government reorganization by Conservative Prime Minister Margaret Thatcher shifting her Cabinet considerably to the right, a bitter television debate among the candidates for deputy leadership of the leftward-moving Labor Party illustrating the depth of its ideological divide, and an opinion survey indicating a Social Democratic-Liberal alliance winning the support of two of five voters.

The Liberals have not held power for more than half a century after being replaced by Labor as one of the two major parties. The Social Democrats formed earlier this year after four former Cabinet members broke away from Labor in disagreement with its militant socialists.

There are now 16 Social Democratic members of Parliament--15 defectors from Labor and one from the Conservative Party--in addition to 11 Liberals, 337 Conservatives, 253 Laborites, 16 from minor regional parties and the non-partisan speaker. Many local council members across the country also have joined the Social Democrats and the new party has won a number of by-elections for local council seats.

The Social Democrats and Liberals intend to retain their individual identities and membership in their electoral alliance, while supporting each other's candidates in the next national election, expected in late 1983 or early 1984. With Liberal support, one of the Social Democrats' leaders, former Labor Cabinet member Roy Jenkins, made a strong second-place showing two months ago in a northern England by-election in a traditional Labor stronghold. This autumn, the Social Democrats will campaign for the Liberal candidate, William Pitt, for a suburban London seat vacated by the death of a Conservative.

Jenkins and other Social Democratic leaders watched from the gallery of the convention in Llandudno, Wales, today as Liberal leader David Steel, a strong supporter of the electoral alliance, engineered its nearly unanimous approval. While voting for it, many Liberal delegates expressed misgivings about difficult details of the new partnership that must still be worked out and the possibility that the new party might try to swallow up the Liberals.

Steel has argued that the grass-roots organizational structure nurtured by the Liberals over those years could combine ideally with the national political reputations and government experience of Jenkins and fellow former Labor Cabinet members Shirley Williams, David Owen and William Rodgers.

"Our supporters and yours now not only hope to break the rigid mold of British politics, we are suddenly ablaze with the realization that it can be done," Williams said in Llandudno last night. "The grim choice between the Conservatives and Labor lays on us the heavy responsibility of offering an alternative."

The Liberal gathering is the first of the annual fall party conferences. Now that the Liberals have agreed to an alliance, the Social Democrats will be under pressure at their first party conference to make specific policy proposals, which they have avoided doing.

The Labor Party must decide at the end of September on a new deputy leader in a contest that symbolizes the battle between the party's left and right wings.

Former energy secretary Tony Benn is the candidate of insurgent militant socialists who want to nationalize more industry, pull out of the European Common Market and ban nuclear weapons and U.S. military bases from Britain. The current deputy leader, Denis Healey, is the champion of the party's old guard opposing all those aims, which the leftists have recently succeeded in enacting as party policy.

The bitterness of the contest, seen by both sides as very close and crucial to the Labor Party's future, was evident in a rancorous nationally televised debate earlier this week involving Benn, Healey and a third candidate, John Silkin.

The angry trading of charges of political disloyalty, extremism and lying was characterized by a leading columnist, Peter Jenkins of the Guardian, as "one of the most unseemly and damaging political spectacles ever seen on television."

Finally, the Conservative Party, at its conference next month, will hear Thatcher explain what she intends to do after this week's government reorganization, in which she fired several Cabinet members who have been critical of her survival-of-the-fittest economic policies.

The Cabinet reshuffle is "a reaffirmation and reinforcement of her economic policy," said a senior government source.