Virginia state Del. Hala S. Ayala won the Democratic Party nomination for lieutenant governor Tuesday, beating five opponents in an expensive race for the state’s second-highest office that revolved around the influence of donors and the possibility of adding diversity to the executive branch.

With nearly all precincts reporting, the unofficial results showed Ayala (Prince William) far ahead of Del. Sam Rasoul (Roanoke), who garnered the second-most votes.

“I understand the struggles so many Virginia families face because I’ve lived them,” Ayala said in a statement that also attacked former delegate Winsome E. Sears (Norfolk), the Republican nominee for lieutenant governor.

Their contest in November will ensure that a woman of color holds statewide office in Virginia for the first time. Sears is Black.

“Virginia families simply cannot afford to have an anti-progress, pro-Trump Lieutenant Governor,” Ayala’s statement said. Sears called Ayala “a radical leftist” who can’t be trusted.

A cybersecurity specialist whose personal story includes losing her father to gun violence as a child, Ayala, 48, entered politics after helping to organize Prince William County residents to attend the 2017 Women’s March.

She then ran for the House of Delegates seat held by former delegate Rich Anderson (Prince William) — the current chair of the state Republican Party — beating him in what was the start of a wave of Democratic victories in Virginia. The Democrats hold a majority in both chambers of the General Assembly for the first time in more than a generation.

Ayala focused on cybersecurity, health care and gun safety legislation during her two terms in the House.

In 2019 she rose to chief deputy House whip, where she wrangled votes for laws passed this year to legalize small amounts of marijuana and to abolish the death penalty. The passage of those measures has energized both parties.

“All of our accomplishments over the last 17 months; she was at the center of all of those accomplishments,” said House Speaker Eileen Filler-Corn (Fairfax), one of Ayala’s key supporters in the race.

The endorsements Ayala received from Filler-Corn, Gov. Ralph Northam (D) and other top Democratic leaders boosted her profile in what was a crowded field. The candidates generally agreed on the party’s core issues, including a call for law enforcement reforms after high-profile cases of police brutality around the country, including in Virginia.

Ayala touted her accomplishments as chief deputy whip and made her mixed heritage — she identifies as African American, Latina, Irish and Lebanese — a focus of her campaign. Her father was born in El Salvador.

“In the 400 years of this commonwealth, we’ve never elected a woman of color,” she said during the race’s only debate in May. “We have an opportunity to make history.”

Like all of the other candidates, she also vowed to raise the profile of the lieutenant governor’s office, whose main duties are to preside over the Senate, serve as a tiebreaking vote on deadlocked legislation and step in to lead the state if the sitting governor resigns or becomes incapacitated.

But Ayala ran into some trouble during the final week before the race, when her campaign disclosed that she received $100,000 from Dominion Energy, her largest donor.

She had earlier pledged to not accept money from the politically powerful utility company. But after taking the money, she said Dominion would not influence her if she were elected.

Clean Virginia, an environmental group funded by Charlottesville hedge fund owner Michael Bills, ran a Facebook ad over the weekend calling on voters to “Reject Hala Ayala and Dominion’s money.”

The group donated $25,000 to Ayala earlier in the race — part of its own effort to build influence in Richmond that, in this race, also included a $25,000 donation to Sean Perryman, the former head of the NAACP’s Fairfax County chapter. The group contributed several hundred thousand dollars to candidates in the two other statewide races.

Some voters Tuesday were swayed by the attacks.

In Richmond, Aryn Carlson said she had been on the fence between Ayala and Rasoul before that revelation, which caused her to choose Rasoul.

“I think clean energy is important,” said Carlson, 45, a physical therapist.

Rasoul faced criticism for his campaign’s heavy reliance on wealthy out-of-state donors, including several connected to Muslim advocacy groups.

The detail led to an uncomfortable moment during the debate when a moderator asked Rasoul if he could guarantee he would represent all Virginians regardless of religious faith. The question generated outrage on his behalf.

Rasoul said the lack of donations from corporations and special interest groups in his campaign showed he wouldn’t be influenced, a claim also made by the other candidates. But some of them also relied on cash from corporations.

Andria McClellan, a Norfolk City Council member, received large donations from current and former executives at the Norfolk Southern railroad company, where her husband is a vice president.

Xavier Warren, an Arlington business consultant, funneled $100,000 of his company’s money into his campaign.

Several voters said they picked Ayala because she brings diversity to the Democratic ticket. Both former governor Terry McAuliffe and Attorney General Mark R. Herring, two White men, won their nomination contests.

“All of the candidates had fairly consistent positions on all the issues that were important to us,” said Rob Duston, 60, of Herndon, referring to himself and his wife. “So it really came down to personality.”

Political analysts say Ayala’s background will help neutralize whatever appeal the Jamaican-born Sears will have among suburban swing voters. The Republican nominee has a chance to become the first Black woman and the first immigrant to serve as lieutenant governor.

“Candidates of different backgrounds are helpful in connecting with a wider range of voters,” said Stephen J. Farnsworth, a political science professor at the University of Mary Washington in Fredericksburg.

Ayala brings extra appeal to liberal voters who may not be excited about seeing the more moderate McAuliffe back in the governor’s mansion, Farnsworth said.

Ayala said that as lieutenant governor she would work to leverage her contacts within the General Assembly to push for additional health-care access for low-income Virginians and broadband access in rural areas.

“I’m ready to hit the ground running and get to work alongside Terry McAuliffe, Mark Herring and all of our Democratic candidates,” she said in her statement.

Laura Vozzella contributed to this report.