Ethan Miller via Getty Images Cortez Masto is a former attorney general of Nevada and the daughter of a Mexican immigrant.

In one of the crucial contests to determine control of the Senate, Democrats succeeded in hanging on to the seat of Senate Minority Leader Harry Reid (D-Nev.) Tuesday, as Democrat Catherine Cortez Masto defeated Republican Joe Heck.

Masto’s victory makes her the first Latina senator.

Reid’s Nevada seat appeared to be the only one in the Senate that Republicans had a good chance of flipping on Election Day. Cortez Masto and Heck were neck and neck in the polls as voters cast their ballots on Tuesday, with Cortez Masto holding a narrow advantage after early voting.

The race was one of a half-dozen or so that would ultimately decide whether Republicans retain their majority in the Senate. Heck, a three-term Republican congressman, struggled to keep himself at arm’s length from Donald Trump, the most unpopular presidential candidate in modern history.

After audio emerged of Trump bragging about sexual assault, Heck announced that he no longer planned to vote for the real estate businessman. “My wife, my daughters, my mom, my sister and all women deserve better. All Americans deserve better,” Heck said.

The blowback from rank-and-file Republicans was fierce, and Heck later cast himself as an undecided voter who was certain not to vote for Democrat nominee Hillary Clinton. He then described Trump as someone who’d make a good commander-in-chief, but wouldn’t clarify how he planned to vote.

Trump’s high unfavorable ratings, and a string of sexual assault allegations, appeared to take a toll on Heck in the weeks leading up to the election, as the Republican’s support slipped among crucial independent voters. And in a year in which many voters wanted a shakeup in Washington, D.C., many saw Heck as an establishment candidate complicit in Beltway gridlock.

Cortez Masto, a former attorney general of Nevada and the daughter of a Mexican immigrant, got a boost from some big names in the run-up to the election. Nevada’s significance in the presidential race and the Senate’s power balance brought both Clinton and President Barack Obama to the state days before ballots were cast.

After being introduced by Cortez Masto at an October rally, Obama cast the race as a choice between electing the first Latina senator, “who believes everyone deserves a chance,” or someone who waffled over supporting Trump. “What the heck?” Obama asked.

Democrats tried to give Clinton and Cortez Masto an edge by running up early-voting numbers that would put Trump and Heck in a hole they couldn’t climb out of. A week out from the election, voting data according to party affiliation showed a significant advantage for Democrats in the crucial Clark County, surrounding Las Vegas. In particular, Democrats were eager to turn out Latino voters who’d be repulsed by Trump’s xenophobia and excited to send the first Latina senator to Washington.

The Senate race was a major test for the Nevada political machine built by Reid, who is stepping down after 30 years in the upper chamber and was intent on leaving it in Democratic control. “I am going to do everything I can do to prevail, to help her prevail,” Reid said in the spring.