Democrats in the Maine Legislature nominated Rep. Aaron Frey for attorney general on Tuesday, all but installing him as the replacement for Gov.-elect Janet Mills in keeping with the State House tradition of picking candidates with legislative experience.

AUGUSTA, Maine — Democrats in the Maine Legislature nominated Rep. Aaron Frey for attorney general on Tuesday, all but installing him as the replacement for Gov.-elect Janet Mills in keeping with the State House tradition of picking candidates with legislative experience.

Frey, 39, a defense attorney from Bangor, won the five-way nominating race for attorney general, the most uncertain race for Maine’s three constitutional offices. The full Legislature will officially pick the attorney general, secretary of state and treasurer on Wednesday.

But the crucial elections were the nominating ones on Tuesday, since Democrats effectively control the offices after winning 110 of 186 legislative seats in the November election. The contentious eras of Gov. Paul LePage and President Donald Trump — both Republicans — led to a surge of interest in the attorney general’s office from well-known Democratic lawyers.

Maine is the only state where the Legislature elects the three constitutional officers, which typically leads to insular races in which candidates travel the state on their own dime or do work on legislative races to round up votes from incoming lawmakers. It has been nearly 40 years since a candidate without legislative experience has been picked as attorney general.

Counts were not released in the nominating election, which took four separate votes, but Frey beat Tim Shannon of Falmouth, outgoing state Sen. Mark Dion of Portland, former attorney general and Sen. Mike Carpenter of Houlton, and Maeghan Maloney, the district attorney in Kennebec and Somerset counties from Augusta, in that respective order on Tuesday.

All of them subtly pushed more aggressive tacks for the attorney general’s office and advocated improving relations with Maine’s Indian tribes. That was a nod to criticism that Mills faced during the gubernatorial primary in which she fended off more progressive challengers.

After his nomination, Frey said among his first moves will be figuring out how the office can be “more proactive” in fighting Maine’s opioid crisis and “starting a conversation about our criminal justice system. He said he hoped to find out “where the conversation went wrong” with tribes.

His election will create a vacancy in his House district, which includes the eastern side of Bangor and a rural part of Orono. He won his fourth term last month, though he will decline to be sworn in alongside other lawmakers on Wednesday to comply with a provision of the Maine Constitution saying a legislator can’t be elected to higher office.

Local party committees will be able to nominate new candidates for Frey’s seat and Secretary of State Matt Dunlap said a special election to replace him will likely happen in February.

Dunlap, a Democrat, is running unopposed for his fourth term as secretary of state. Democrats also picked former state Rep. Henry Beck of Waterville as their nominee to challenge State Treasurer Terry Hayes, a Buckfield independent.

Hayes, who ran unsuccessfully for governor this year, won two terms by gaining support from Republicans and siphoning some Democratic votes. Her road to re-election will be tougher on Wednesday with stronger Democratic control of the Legislature.

For a roundup of Maine political news,click here to receive Daily Brief, Maine’s only newsletter on state politics via email on weekday mornings.