Democratic challenger Jared Golden beat Republican incumbent Bruce Poliquin in a closely contested race for Maine’s second congressional district, the secretary of state determined Thursday after running the state’s unique ranked-choice tabulation process.

Mr. Golden’s victory and another Democratic win—declared late Thursday by the Associated Press, by law professor Katie Porter over GOP Rep. Mimi Walters in California—gave Democrats a net pickup of 36 House seats with six GOP-held districts left outstanding.

Democrats...