Detroit — Dana Nessel will head into the fall election season as the Michigan Democratic Party’s choice for attorney general after winning a combative endorsement election over Pat Miles on Sunday and overcoming opposition from the powerful United Auto Workers union.

The Plymouth Township attorney, best known for helping topple Michigan’s same-sex marriage ban, pulled out a narrow victory over Miles at a boisterous convention attended by more than 6,700 Democrats, including many “progressives” who joined the party to back her candidacy.

Dana Nessel talks about the attorney general role after she receives the Michigan Democratic nomination. Robin Buckson / The Detroit News

“I just really want to restore dignity to the office of attorney general, and I want it to turn back into an office that I think protects the residents of the state instead of persecuting them,” Nessel told reporters after her election.

Miles, a former U.S. attorney for the Western District of Michigan, conceded to Nessel before the vote total was announced. Backed by the UAW, a traditional power broker, his defeat signals an ongoing sea change in the party, which is being reshaped by an influx of “progressive” grassroots activists.

“It’s historic,” said longtime political pundit Bill Ballenger, who served in the state Legislature as a Republican but has attended several Democratic conventions as a media member. “The labor slate always wins, and that’s the UAW.”

Officials and activists hailed the robust convention turnout as a sign of party energy and enthusiasm leading up to the mid-term election, the first since Republican President Donald Trump won the state over Democrat Hillary Clinton.

About 2,000 delegates voted in a similar endorsement election in 2010. Democrats will formally nominate statewide candidates after the gubernatorial primary in August, but the early backing is intended to give candidates for attorney general, secretary of state and the Michigan Supreme Court a head start on their general election campaign and fundraising efforts.

Democrats also endorsed Jocelyn Benson for Michigan secretary of state, along with appellate attorney Megan Kathleen Cavanagh and University of Michigan professor Samuel Bagenstos for the Michigan Supreme Court. All three were unopposed at the convention.

 The attorney general’s race proved a bruising affair, with Nessel labeling Miles a flip-flopper for shifting policy stances on things like marijuana legalization. Miles this week blasted Nessel for raising concerns over state legislation that would extend the statute of limitations in sexual conduct cases involving minors, a response to the Larry Nassar scandal at Michigan State University.

U.S. Sen. Gary Peters was among those urging fellow Democrats to move past internal grudges and unite to take on Republicans in the fall.

“I hope you all agree we can’t say, ‘Well my candidate didn’t win, and the one who won is too progressive, not progressive enough, too centrist, not centrist enough, voted this way, voted that way’ — enough is enough,” Peters said in convention speech.

“We need to be united, or we will not win.”

Benson, a Harvard Law School graduate and Wayne State University law school dean from 2012 to 2016, was also the party’s nominee for secretary of state in 2010 but lost by 6 percentage points to current office holder Ruth Johnson, a Republican.

In her endorsement acceptance speech, Benson said she’d fight to keep wait times at the secretary of state’s office under 30 minutes, to make the state a national model for election security and to implement no-reason absentee voting. Benson vowed to “shine a light” on state government working on behalf of the wealthy and lobbyists.

“Let’s take Michigan from worst to first in transparency and ethics,” she said.

Cavanagh and Bagenstos will run against justices Kurtis Wilder and Beth Clement, who are seeking election after appointment last year by GOP Gov. Rick Snyder. Republican nominees hold a 5-2 majority on the court.

Cavanagh’s endorsement was moved by her father, Michael Cavanagh, a former justice on the Michigan Supreme Court. Megan Cavanagh stressed that she was her “own person” and committed to changing the makeup of the court.

“We are going to start writing majority opinions instead of dissenting opinions,” she said.

Bagenstos referenced his past work as he promised to defend women’s rights, collective bargaining, and the fundamental right to vote.

“I will fight for all of our rights on the Michigan Supreme Court,” Bagenstos said.

Nessel, a private practice attorney and former Wayne County assistant prosecutor, courted the growing liberal wing of the Michigan Democratic Party and helped organize a convention busing scheme that helped supporters from across the state make it to the Cobo Center in Detroit despite a winter storm and freezing rain that left roadways slick.

Nessel said she believes the party was ready for a more unconventional candidate and unconventional race, one that will contribute to a “blue wave” in November. She was backed by the Michigan Education Association, but other establishment powers had rallied behind Miles in the weeks leading up to the convention.

“Whether or not the leadership of some of the unions supported me, I support the unions in this state,” Nessel said. “I support workers.”

Party Chairman Brandon Dillon credited Nessel with bringing more Democrats into the political process, which he said could bode well for the fall.

“In an election where turnout and enthusiasm are going to be important, she has a potential to activate a lot of new voters,” Dillon said. “The party has new energy, new blood, and she was able to capitalize on that.”

The challenge for the party, he said, is “to keep this energy moving in the right direction.”

If elected in the fall, Nessel would make history as Michigan’s first openly gay statewide office holder. She is expected to face either House Speaker Tom Leonard or state Sen. Tonya Schuitmaker, who are competing for the GOP nomination for attorney general, in the general election.

Nessel’s nomination could also leave Democrats without an African-American in a policy-making position at the top of the November ticket, although many expect gubernatorial frontrunner Gretchen Whitmer to pick a person of color as her running mate.

That could depress turnout in cities like Detroit with a large African-American base, said Jonathan Kinloch, a Miles supporter and chairman of the 13th Congressional District.

“It’s not to say this isn’t a ticket that can win, but it’s going to be a ticket that’s going to be tough to sell to some of the folks in my neck of the woods, he said.

Miles and Nessel each signed pledges they would withdraw from the attorney general’s race if they lost Sunday’s endorsement vote, and Miles made good on his commitment.

“I fully expect all of my supporters to give her the backing … and I would fully support a Democratic ticket in the fall,” he said.

Nessel’s supporters flooded Cobo Center with chants of “Dana.”

“I look at the attorney general now, and all they do is protect special interests and corporate interests and bad government state actors, when really they should be protecting the rest of us who live in this state,” Nessel told 9th Congressional District Democrats.

Nessel was also endorsed by MI Legalize, a pro-marijuana legalization group. Pot emerged as an early issue in the race, with Nessel vocally backing legalization and Miles saying only that he would enforce any law approved by voters, a position he shifted in March by backing the likely 2018 ballot measure.

Miles, in a series of caucus speeches, promised voters change from current Attorney General Bill Schuette, a Republican candidate for governor, promising protections for both the environment and the most vulnerable and unity moving forward.

“After today, we’re going to unify as a party,” Miles told a group from Michigan’s 6th Congressional District.

Kristin Laesser traveled to Detroit to cast her vote for Nessel.

“I like what she’s got to say,” the 29-year-old Macomb Township woman said. Laesser said she hoped her vote would help deter a Miles victory.

“He’s got the union backing, but from what I hear he’s not really pro-union at all,” Laesser said. “Plus, we need women on the ballot.”

William Noakes, a former U.S. Securities and Exchange Commission attorney, was also seeking the attorney general endorsement but did not collect enough member signatures to qualify for the convention ballot.

Joheina Hussein attended the convention Sunday with members from the Arab Student Union at Fordson High School in Dearborn.

Hussein, 16, is too young to cast a vote at the convention, but wanted the chance to hear the changes each candidate was promising.

“It they do get elected into office, I want to see if those goals are achieved,” Hussein said.

“That it’s not all talk,” her classmate, Heba Chokr, added.