Amazon.com Inc. warehouse workers in New York voted to establish the tech giant’s first union in the U.S., providing a major victory for labor activists who have long sought to bring representation to the nation’s second-largest private employer.

Employees at the JFK8 facility, Amazon’s largest in Staten Island, voted 2,654 to 2,131 in favor of organizing, the National Labor Relations Board said Friday. That gave the labor group, which calls itself Amazon Labor Union, a clear majority of the total votes cast, even with several dozen challenged or voided ballots. More than 57% of the facility’s roughly 8,300 eligible voters cast valid ballots, according to NLRB data.

It could take months or longer for JFK8 workers to reach a first union contract. But Friday’s results are set to galvanize activists who already have triggered votes at two other Amazon facilities, and have stepped up their efforts in recent years as Amazon has rapidly added workers and grown into a pacesetter for the wages, benefits and hiring practices of companies in many regions. Amazon employs roughly one million people in the U.S., behind only Walmart Inc.

“Today the people have spoken, and the people wanted a union,” Chris Smalls, who has led the organization effort among Amazon’s Staten Island workers, said at a press conference after the vote.

Amazon said it was “disappointed with the outcome of the election in Staten Island because we believe having a direct relationship with the company is best for our employees.” In a statement, the company added that it is evaluating options that could include filing objections against the NLRB, which it alleged exerted improper influence in the election. Amazon didn’t elaborate. An NLRB spokeswoman said it is independent and that any of its actions against Amazon have been consistent with enforcing labor law.

U.S. unions broadly have been pressing to increase their ranks and secure gains for their members amid the tighter labor market of the pandemic era, seeking to reverse long-term declines in private-sector union membership. In 2021, a record low 6.1% of private-sector workers were members of a union, according to the Labor Department.

Several big U.S. companies have contended with union actions over the past year, including Starbucks Corp. , where baristas at a Buffalo, N.Y., store voted in December to form the first labor union at one of the coffee giant’s own U.S. cafes in its 50-year history. Several other Starbucks stores have voted to unionize since, including one last month in the coffee chain’s hometown of Seattle.

Groups of Amazon employees have pushed for enhanced job security and better compensation and working conditions for years, but the company had prevailed in previous elections. Now Chief Executive Andy Jassy, who took the job from founder Jeff Bezos last year, faces labor activists seeking to leverage pandemic-era employee empowerment and a labor market that is tighter than at any time in many decades.

The election at JFK8 is one of two votes at Amazon facilities in Staten Island in a month. An election at a warehouse named LDJ5, which employs about 1,500 workers, is scheduled for the week of April 25.

Amazon workers were celebrating outside the National Labor Relations Review Board offices in New York City, after hearing preliminary vote results Friday.

Photo: BRENDAN MCDERMID/REUTERS

Counting in a separate election at a company warehouse in Alabama was close enough to require a hearing, the NLRB said on Thursday. That could take place in the next several weeks.

Amazon workers at the Alabama facility overwhelmingly voted against unionization last year, but the labor board ordered a revote after finding that Amazon acted inappropriately during the campaign. The company denied any wrongdoing.

Amazon during the pandemic has hired hundreds of thousands of workers and built dozens of new logistics hubs to help handle a surge in orders brought about by Covid-19 lockdowns. In the process, it has dealt with protests and concerns from some workers about the pace at which they are expected to prepare packages, the repetitive nature of their work and lack of protections in disputes with Amazon. The company in response has bolstered some of its safety training, voiced its commitment to workers, and pointed to its pay and benefits, which include healthcare and 401(k) offerings and paid tuition options. Its starting pay is more than two times the national minimum wage.

For Edgar Varela, an employee at the JFK8 facility, those benefits were sufficient reason to vote against the union. The 29-year-old said he doubted organizers’ ability to negotiate effectively with the company, given the union’s newness.

“Realistically, I just think sticking with just Amazon is the smarter choice,” Mr. Varela said. “Right now, the pay is great.”

Others found the union’s case persuasive. Shannon Jones, 29, said she voted for the union in the hopes it will pressure Amazon to provide longer breaks, address safety and cleanliness issues at the warehouse, and increase pay amid higher inflation. “A lot of things have to be changed that they weren’t willing to change,” she said of Amazon.

Mr. Smalls has aimed to organize workers at several Amazon facilities in Staten Island and across the U.S. A former Amazon employee, he was fired by the company in 2020 in what he said was retaliation for his attempts to organize workers. Amazon said he violated safety protocols related to Covid-19.

Organizers ran into several challenges. Amazon has primarily used meetings inside of its facilities to campaign against unionization, emphasizing Amazon Labor Union’s inexperience and potential fees that unionized workers would pay, according to employees. Many workers also don’t stay long at Amazon, making it difficult to build and sustain support for a union.

Amazon Labor Union last year had to resubmit its election petition after being forced to withdraw it late last year when it initially failed to prove to the NLRB it had a sufficient amount of backing from workers.

“It’s always an uphill battle for unions,” said Rebecca Givan, a labor studies professor at Rutgers University. “People see enough workers sign a card showing union support and think maybe the next steps are straightforward, but they’re not.”

Still, major unions such as the International Brotherhood of Teamsters are continuing to focus on Amazon. “What these elections show is Amazon workers want a union,” said Sean O’Brien, general president of the Teamsters.

The Biden administration has strongly endorsed efforts by organized labor. Labor Secretary Marty Walsh congratulated the union on Friday’s outcome. “This is historic, and will result in more workers getting a seat at the table to advocate for the conditions they want to see in their workplace,” he said on Twitter.

Business groups have charged that the NLRB under President Biden favors organized labor.

Amazon has run into recent problems with the NLRB. In March, the labor group sued Amazon in a case that involved a former employee in Staten Island named Gerald Bryson, whom the company fired in 2020 after his involvement in a protest related to Covid-19 working conditions. Amazon said Mr. Bryson violated company policies related to harassment and language, but the NLRB said it found that Mr. Bryson was wrongly terminated in retaliation for organizing. The labor board has asked a federal court to force the company to give Mr. Bryson his job back.

The U.S. Chamber of Commerce, in a blog post last month, called the NLRB’s decision in that case questionable and suggested the timing might have been intended to sway worker sentiment against Amazon in the union vote.

An NLRB representative reiterated Friday that it is independent and has acted consistently with enforcing labor law.

The lawsuit followed a complaint the board issued against Amazon in January that alleges the company broke labor laws by threatening, surveilling and interrogating company workers at the JFK8 facility. An Amazon spokeswoman said the company looks forward to proving that the allegations are false. The complaint will be heard before an NLRB administrative law judge.

Write to Sebastian Herrera at Sebastian.Herrera@wsj.com and Allison Prang at allison.prang@wsj.com