Members of Boeing’s machinists union on Friday voted by a slim margin to accept the company’s proposal of a long-term contract that will guarantee construction of a new long-range wide-body aircraft in the Puget Sound region, in exchange for significant wage and retirement benefit concessions.

The new contract means Boeing will build a composite wing for the new 777X plane and will assemble the final product in its Everett, Wash., plant. Boeing already has about 80,000 employees in facilities around the Puget Sound region, and the new contract means the 20,000 or so who will work on the 777X will be located in Washington state for at least the next decade.

The vote came two months after the International Association of Machinists and Aerospace Workers (IAM) rejected an earlier offer from the company by a two-to-one margin. Despite a proposed $10,000 signing bonus, the machinists were furious over a provision in that version of the contract that would have moved their retirement plans away from pensions and toward 401(k)-style savings plans. Angry protests erupted at union halls, and one union leader tore up copies of the contract in front of the media.

Boeing was not subtle in its response to the rejection. After the vote, Boeing immediately began soliciting bids from other states; about two dozen states applied, some offering major tax breaks valued in the billions of dollars. Boeing executives told Washington state elected officials earlier this week that another rejection by the machinists union would guarantee that the 777X project would be located outside Washington state.

That would have been a big blow to the state’s economy, and to its self-image. Boeing, founded in Seattle a century ago, has been a cornerstone of the regional economy for decades, though in recent years the company has moved its corporate headquarters to Chicago, a key assembly line to South Carolina, and other units to Utah, California, Missouri and other states.

Washington state officials had estimated that the 777X line was worth about 20,000 jobs and more than $20 billion in economic activity.

After the initial contract offer, which was soundly rejected, Boeing sweetened the deal by adding another $5,000 bonus to be paid to machinists in 2020, better dental coverage and a tweak to the union’s wage structure. The changes to the company’s retirement plan remained in place.

Those minor concessions, along with the threat of losing thousands of jobs, was enough to scare union members into voting in favor. The contract proposal passed by a 51 percent to 49 percent margin — a difference of 600 votes, one union leader told the Seattle Times.

“The impact of this agreement extends far beyond [IAM] members who voted today,” IAM President Tom Buffenbarger said in a statement released Friday night. “For decades to come, the entire region will benefit from the economic activity and technological innovations that will accompany the production of the 777X and the 737 MAX.”

The new contract also guarantees the company will produce the 737 MAX, a new version of the company’s most popular commercial aircraft, through at least 2024.

The vote, and Boeing’s commitment to continue building the new aircraft in Washington state, means the company will be able to take advantage of the largest corporate tax break in the history of the United States. The Washington state legislature, meeting in special session last fall, passed a series of tax breaks worth up to $8.7 billion through 2040, contingent upon construction of the 777X staying in Washington. Gov. Jay Inslee (D) signed the tax break in November.

The contract vote is also good political news for Inslee, who took heat for appearing to urge the machinists to vote in favor of Boeing’s latest offer last month. Several top union officials refused to attend the first Christmas party Inslee threw in the governor’s mansion, a snub they said was directly related to Inslee’s comments on negotiations between the machinists union and Boeing. Inslee kept a lower profile in the following weeks, and he made clear several times he wouldn’t publicly urge machinists to vote a certain way.

In a statement Friday, though, Inslee trumpeted the results.

“Tonight, Washington state secured its future as the aerospace capital of the world. To make that happen, the International Association of Machinists District 751 took a hard vote that demands the respect of all Washingtonians who will benefit from having Boeing build the 777X here,” Inslee said. “With the work the Legislature did in November and tonight’s vote, Washington state has shown it is the only place to build this next generation jetliner. That legislation has important protections for taxpayers and for Machinists and we will make sure the company keeps its commitment and that these jobs remain in Washington state for the life of the airplane.”

Since being sworn in early in 2013, Inslee has had a rocky first year as governor. But the Boeing contract and the company’s commitment to keep jobs in the state could prove a strong start to his second year in office.

“Governors [who] deliver Boeing jobs win reelection. Period,” said one Washington state Democratic strategist outside of Inslee’s orbit.