Matt Dunlap defeated a candidate backed by the House Democratic campaign arm and is set to face former Gov. Paul LePage, a Republican, in a competitive general election.
Mr. Charles, a conservative Republican, had led the field ahead of a ranked-choice runoff. But Ms. Pingree, a former Maine House speaker, had been in a tight race with other Democrats.