Rob Bennett for The New York Times; Suzanne DeChillo/The New York Times

ALBANY – Republicans apparently seized control of the New York State Senate on Monday, in a stunning and sudden reversal of fortunes for the Democratic Party, which controlled the chamber for barely five months.

A raucous leadership fight erupted on the floor of the Senate around 3 p.m., with two Democrats, Pedro Espada Jr. of the Bronx and Hiram Monserrate of Queens, joining the 30 Senate Republicans in a motion that would displace Democrats as the party in control.

In a news conference in the early evening, Senator Malcolm A. Smith of Queens, leader of the Senate Democrats, insisted that the Republican-engineered vote was illegal and violated parliamentary procedure. He said the vote was illegal because it had already taken place after the meeting was already brought to an end.

Giovanni Rufino for The New York Times

It was a noisy and acrimonious scene on the floor of the Senate as Senator Thomas W. Libous, a Republican from Binghamton and the party’s deputy leader, shouted for a roll-call vote, while Democrats attempted to stall the vote by asking to adjourn the session.

All 30 Republicans stood with their hands raised, signaling a vote for a change in leadership. Mr. Espada and Mr. Monserrate joined them, each raising his hand. Republicans won the vote by a 32-to-30 margin. The Senate will now be governed under a new joint leadership structure, with Mr. Espada serving as the president pro tempore, and Senator Dean G. Skelos, of Long Island, as the new majority leader.

After the results of the vote were read aloud, the in-house television station that carries Senate proceedings live in the Capitol went dark. All that appeared on the screen was a still photo of the Senate chamber and the words “Please stand by.”

Senate Republicans quickly claimed that they were on the verge of controlling the chamber. “A new bipartisan, coalition is being established that is bringing real reform to the Senate right now,” Republicans said in a statement emailed to reporters at 3:20 p.m.

As the events were unfolding on the floor, Mr. Smith huddled in the hall just off the Senate chamber and consulted with his staff. When asked what was occurring, he responded, “I’m trying to find out right now.”

Mr. Smith held a news conference in the early evening, denouncing the Republican maneuver as “scurrilous” and insisting that the Democrats were still in charge. He insisted the vote was illegal because it had taken place after the session had already been adjourned.

“It’s sad that the Republicans would chose to disrupt the business of this house,” he said. “We have many crucial issue that are important to us that has to get done, some of which are expiring, and obviously for them it was all about politics and not about the 19.5 million people in the state of New York. And I would hope that the public is outraged. I hope that the public will call their senators, the Republican senators, and say, ‘How dare you?'”

Mr. Smith added: “Let’s just be very clear, very clear, that the Senate majority is still in Democratic hands and will be in Democratic hands. And we will finish our business and we will adjourn and go home at the appropriate time.”

Earlier, at 4:44 p.m., Mr. Smith’s office released a statement insisting that control of the Senate had not changed hands.

“This was an illegal and unlawful attempt to gain control of the Senate and reverse the will of the people who voted for a Democratic majority,” Austin Shafran, a spokesman for Mr. Smith, said. “Nothing has changed. Senator Malcolm A. Smith remains the duly elected temporary president and majority leader. The real Senate majority is anxious to get back to governing, and will take immediate steps to get us back to work.”

Also, Hank Sheinkopf, an adviser to Mr. Smith, denounced the senators behind the revolt. “This is obviously an attempt by a couple of people to get personal power at the expense of the taxpayers,” Mr. Sheinkopf said. “It disrupts the Senate at a critical period, when issues like mayoral control are yet undecided. And the taxpayers are going to remember these guys by first and last name next year.”

Until January, Republicans had controlled the State Senate for more than four decades. Democrats won a majority of Senate seats in the November elections, but only after three dissident senators who were being courted by Republicans, including Mr. Espada and Mr. Monserrate, agreed to elect Mr. Smith.

Why Mr. Espada and Mr. Monserrate suddenly defected on Monday afternoon was not immediately clear. Both men are under investigation by the authorities. The state attorney general’s office is investigating a health care agency, Soundview HealthCare Network, that Mr. Espada ran until recently. And Mr. Monserrate, who was indicted on felony assault charges in March stemming from an attack on his companion, would automatically be thrown out of office if convicted.

If Mr. Monserrate is convicted, the Senate would be evenly split between the parties, 31 to 31. But with the lieutenant governor’s office vacant until the 2010 elections, there would be no tie-breaking vote in the chamber unless one or more other senators changed sides.

The coup could also complicate prospects for Gov. David A. Paterson, who is fighting to build a record on which to run for re-election and who requires a functioning Senate in order do so.

One source of contention among Democrats recently has been Mr. Smith’s support for same-sex marriage. Senator Rubén Díaz Sr., a Democrat from the Bronx, has been outspoken in his insistence that legislation allowing gay couples to marry not be allowed to come to a vote. Some had speculated he might leave the Democratic Party if Mr. Smith were to allow a vote.

But Mr. Díaz did not join Mr. Espada and Mr. Monserrate in the leadership vote on Monday. It was not immediately clear whether the same-sex marriage legislation played any role in the leadership dispute.

One person backing the revolt to put Republicans back in charge was Tom Golisano, the Rochester businessman and founder of Responsible New York, a political action committee that gave thousands of dollars to Senate Democrats last year to help them take control of the Senate, but who has become increasingly critical of the party. Mr. Golisano recently announced that he was moving his legal residence to Florida out of anger about the budget deal crafted in April by Democratic leaders in Albany, which included an increase in taxes on high earners.

Mr. Golisano played a role in negotiating original deal under which Mr. Espada and Mr. Monserrate — along with Mr. Díaz and Senator Carl Kruger of Brooklyn — gave their support to Mr. Smith. Steve Pigeon, his aide de camp, has been a frequent presence in Albany in recent weeks, and said Monday that Mr. Golisano felt betrayed by Mr. Smith because the Democratic leader had not delivered the overhaul of Senate rules he had promised upon taking power.

“He feels very strongly that he backed Malcolm Smith, and Smith didn’t keep his word, and didn’t make the changes he said he would,” Mr. Pigeon. “What you will see now is power-sharing, real reform.”

The apparent change of power sent shock waves in political circles across the state. At City Hall, in Lower Manhattan, stunned members of the New York City Council walked into the press room to watch the news unfold on local television. “I’m floored,” said Vincent M. Ignizio, a Republican city councilman and former state assemblyman from Staten Island.

To balance its budget for the next year, the City Council needs Albany to approve two proposed sales tax increases. “This will turn the budget process on its head,” Mr. Ignizio said.

Michael Barbaro and Nicholas Confessore contributed reporting from New York City.