SEATTLE — Under pressure from regional leaders, machinists in Washington state took a late-night vote that defied their local union bosses by narrowly approving a new labor contract that secures a coveted plane project for the Seattle area but moves workers away from pensions.

The tight count exposed deep rifts in the once-powerful union, but with plenty of states lining up to give Boeing exactly what it wanted to get work on the 777x, the aerospace giant had a tremendous advantage.

The company, the state’s governor and national union leaders all hailed the contract as a vital boost to the region’s economy, but to some observers the vote dealt a blow to local union influence.

“It shows that even a strong local is vulnerable and has a limited defensibility to slow the tide of concessions that has been going on across the country,” said Leon Grunberg, a sociology professor at the University of Puget Sound who co-authored a book, “Turbulence: Boeing and the State of American Workers.”

He added Saturday, “This is happening with a company that’s doing very well financially.”

Members of the International Association of Machinists and Aerospace Workers approved an eight-year contract extension late Friday by 51 percent, a turnaround from November when the same workers voted down a previous offer by 67 percent.

The passing margin was about 600 votes of about 23,900 counted, according to Wilson Ferguson, president of a local unit of District 751.

Ferguson said the vote diminished the local union’s power since it conceded some hard-fought benefits they won’t be getting back.

Opponents of the contract opposed the idea of freezing the Machinists’ pensions and moving workers to a defined-contribution savings plan.

Local union officials had urged their 30,000 members to oppose the deal, arguing that the proposal surrendered too much at a time of company profitability. They had opposed taking a vote at all but were overruled by national leaders in the Machinists union.

A number of political leaders including Washington Gov. Jay Inslee praised the vote, which supporters said keeps thousands of well-paying jobs in the state and solidifies Boeing’s presence in the Seattle area where the company built its first airplanes nearly a century ago.

Inslee, a Democrat, said after the vote that it secured Washington state’s “future as the aerospace capital of the world.”

Some local leaders said there was no other choice but to vote “yes.” Bob Drewel, a former Snohomish County executive, had said the Boeing work could be worth 20,000 jobs and $20 billion for Washington.

Grunberg, the professor, said in an interview Saturday, “Everybody was scared about Boeing moving this huge new production out of state, so I think there was tremendous anxiety about losing this production.”

More than 20 other states moved recently to bid on the 777x contract.

U.S. Sen. Patty Murray on Friday said the decision wasn’t an easy one and workers’ concerns about income and retirement security were legitimate. But the Democrat also said the agreement “guarantees that thousands of good-paying jobs and billions of dollars in economic growth.”

Under the terms of the eight-year contract extension, Boeing said the 777X and its composite wing will be built in the Puget Sound area by Boeing employees represented by the Machinists union.

Boeing Commercial Airplanes President and CEO Ray Conner said Friday that “the future of Boeing in the Puget Sound region has never looked brighter.”

The announcement that the contract had passed was somber at the union hall in Everett.

“People that voted for it were scared,” said Hazel Powers, who has worked for Boeing for nearly 35 years. “The pressure from the politicians and the community — people are scared about not having good paying Boeing jobs.”

Ferguson, the local union leader, said Saturday morning: “This was a turning point in the labor movement. Pensions were hard fought battles to get in the first place. Once they’re gone, they’re gone.”

“Their fear and intimidation worked,” he added.