WASHINGTON — Depleted by decades of diminishing reach and struggling to respond to recent anti-union laws, the labor movement has nonetheless found a way to assert itself politically by wreaking havoc on President Obama’s trade agenda, a top priority of his final years in office.

On Friday, stiff labor opposition helped derail a measure necessary to clear a path for an up-or-down vote on a sweeping trade deal that the White House is negotiating with 11 other nations bordering the Pacific Ocean.

“Labor worked on this long and hard,” Representative Gregory Meeks, a Queens Democrat sympathetic to the emerging deal, known as the Trans-Pacific Partnership (T.P.P.), said on the eve of the vote. “If labor was neutral on this issue, and members were allowed to just make a decision on their own, this bill would not have a problem in passing.”

While a broad coalition of unions and liberal activists can claim credit for beating back the president’s favored legislation, the key to labor’s display of force in Congress, according to supporters and opponents of the trade deal, was the movement’s unusual cohesion across various sectors of the economy — including public employees and service workers not directly affected by foreign competition.