Democratic U.S. Rep. Keith Ellison will be Minnesota’s next attorney general, defeating Republican Doug Wardlow after a bitter campaign marked by allegations of domestic abuse and an intense spotlight on both candidates’ pasts.

Ellison helped deliver the DFL Party a sweep of the statewide elected offices and was met by a raucous room of supporters chanting his name at the party’s election night celebration in St. Paul. Ellison acknowledged the difficulty of the race but said his campaign persevered thanks to his supporters.

“Every single day I will wake up and I will fight to protect the rights of all of us,” Ellison said.

Ellison said “we are all in this together” and that “we are not going to cast anybody away.” “Immigration is a good thing,” he shouted, “having a good-paying union job is a good thing.”

Minnesota voters encountered two candidates who offered starkly different visions for how they would lead the office and two men who spent months painting the other as political radicals.

Ellison, who is also deputy chairman of the Democratic National Committee, has risen to national political prominence since becoming the nation’s first Muslim congressman in 2006. In June, he surprised supporters by announcing that he would give up a safe Democratic House seat to pursue the Attorney General’s Office after Lori Swanson filed to run for governor. Ellison won the DFL Party’s primary just days after ex-girlfriend Karen Monahan alleged that he emotionally and physically abused her.

Gallery: Keith Ellison defeats Doug Wardlow for Minnesota attorney general Gallery: Keith Ellison defeats Doug Wardlow for Minnesota attorney general

Ellison, 55, of Minneapolis, has denied Monahan’s claim, and an investigation commissioned by the DFL Party concluded that it could not substantiate the allegations. Republicans dismissed the investigation because the attorney who led the probe works for a law firm that has represented DFL Party interests.

Momentum swung back and forth in the race, with both candidates claiming an advantage in a series of recent polls. Wardlow, a former one-term Republican state representative from Eagan, pulled ahead in October in a Star Tribune/MPR News Minnesota Poll of 800 likely voters between Oct. 15-17. Wardlow led Ellison by 7 points, a month after Ellison earned a 5-point edge in a previous poll. Last week, a KSTP/SurveyUSA Poll of 1,000 Minnesota adults showed Ellison with a 4-point lead.

The election promises to usher in a new era for an office led by Swanson since 2006. Ellison has said that he would approach the office as a tool to challenge certain Trump administration policies in court as other state attorneys general have since Donald Trump’s election. Wardlow, 40, instead pitched a more narrow focus on Minnesota and has said Swanson’s involvement in suits challenging Trump policies like the 2017 travel ban were a misuse of the office’s resources.

Ellison said recently he would make as his “first legislative priority” safeguarding staff attorneys from being fired based on their politics — a proposal that was in direct response to a recording of Wardlow pledging to a group of Republican donors that he would purge the office of 42 DFL attorneys.

“I hereby pledge to you that the only criteria for working in the Minnesota Attorney General’s Office is if you will serve the public interest,” he said late Tuesday.

Before launching his campaign, Wardlow also worked for the national Alliance Defending Freedom, a conservative Christian nonprofit legal group behind numerous court challenges to same-sex marriage and transgender rights. Wardlow, a Georgetown University Law Center graduate, has since said his views on such topics are not relevant to the work he would carry out as attorney general.

Late last month, a former high school classmate of Wardlow’s stepped forward to accuse the Republican of bullying him because he was gay, which Wardlow has denied.

Ellison has a long history of progressive community activism and spent two terms in the Legislature before being elected to Congress. While running for attorney general, he again came under attack for his past association with Louis Farrakhan, the anti-Semitic leader of the Nation of Islam, and for representing the leader of a Minneapolis gang linked to the 1992 slaying of a local officer. Ellison also spoke out in 2000 in support of two women who either killed or attempted to murder police officers.

The DFL Party has stuck behind Ellison since after his primary win, but the investigation it ordered to look into Monahan’s allegation that Ellison tried to drag her off a bed during a 2016 argument failed to produce the clear answers that many sought.

Jerod Greenisen, 27, a St. Paul resident who works for a website design and development agency, said Tuesday that he was uncertain about Ellison for attorney general.

Still, Greenisen added: “I ended up voting for him just because I didn’t think I necessarily had enough information to discredit all the positive things about him.”

Grassroots-Legalize Cannabis candidate Noah Johnson was also on the ballot but threw his support behind Ellison last month. Former Ramsey County Attorney Tom Foley, who lost the DFL primary, re-entered the race as a write-in candidate.

Also Tuesday, Secretary of State Steve Simon defeated Republican challenger John Howe, a former state senator and mayor of Red Wing.

Democrat Julie Blaha defeated Republican Pam Myhra in the race to elect a new state auditor for the first time in more than a decade. The winner will replace Rebecca Otto.

Staff writer Emma Nelson contributed to this report.

Correction: The headline of an earlier version misidentified Steve Simon.