ALBANY  The Democrats’ tenuous control of the New York State Senate abruptly collapsed on Monday, throwing the Legislature into chaos with just two weeks remaining in its session.

Two dissident Democrats, who had been secretly strategizing with Republicans for weeks, bucked their party’s leaders and joined with 30 Republican senators to form what they said would be a bipartisan power-sharing deal. But the arrangement effectively re-establishes Republican control.

The change upends the agenda in Albany, where Democrats had assumed power in the Senate in January, with 32 seats, after more than 40 years in the minority. Democrats were pushing bills to give tenants more rights, strengthen abortion rights and legalize same-sex marriage this session. And the move underscores the continuing tumult of New York politics, where there have been three governors in less than three years and four Senate presidents since last summer.

Democratic leaders were caught off guard as the Republicans and the two Democratic dissidents, Pedro Espada Jr. of the Bronx and Hiram Monserrate of Queens, moved to topple them, and at one point became so flustered that they turned out the lights in the Senate chamber to try to prevent Republicans from installing new leaders.