SAO PAULO — President Michel Temer has signed into law a controversial labor reform that is a key part of his plan to revive Brazil’s moribund economy and boost his own embattled leadership.

A dramatic sit-in in the Senate earlier this week threatened to sink the bill, but the body eventually passed it.

Temer has been heralding the victory this week as he fights for his political life in the face of a corruption charge. The lower house of Congress will decide if he stands trial.

Temer argues that the labor law and other measures will help bolster Brazil’s economy, which recently began growing again after a prolonged recession. The legislation will allow agreements negotiated between employers and workers on a range of issues to override current labor law.