SANAA, Yemen – Struggling to hold power after many of his allies abandoned him, Yemen’s longtime leader on Wednesday escalated his confrontation with a rapidly expanding uprising and took on emergency powers that give him a freer hand to quell protests.

A legislature full of his supporters granted President Ali Abdullah Saleh’s request for a 30-day state of emergency, which suspends the constitution, bars protests and gives security forces far-reaching powers of arrest.

The opposition called the vote illegal and vowed to press on with its campaign to topple Saleh’s regime.

The move underlined Saleh’s desperation in the face of month-old protests that have attracted tens of thousands across his impoverished nation in the southern corner of the Arabian Peninsula. This week, Saleh’s regime was hit by a wave of defections by military commanders, ruling party members and others, swelling the ranks of the opposition and leaving the president isolated.

Saleh has repeatedly sought to appease the protesters but to no avail.

Over the past month, he has offered not to run again when his current term ends in 2013, then offered this week to step down by the end of this year and open a dialogue with the leaders of the demonstrators.

At the same time, he has stepped up the use of violence. His security forces shot dead more than 40 demonstrators in Sanaa on Friday.

The state of emergency declaration appeared to signal that Saleh intends to dig in and try to crush his opponents.

The decree allows media censorship, gives wide powers to censor mail, tap phone lines, search homes and detain suspects without judicial process.