MINNEAPOLIS (AP) -- Rep. Tim Walz has won Minnesota's open race for governor, keeping Democrats' hold on the state's top office.

Walz defeated second-time Republican candidate Jeff Johnson. Democratic Gov. Mark Dayton chose not to run for a third term.

Walz was ahead in public polling throughout the race, but his victory was still unusual. It marks the first time one of Minnesota's political parties has held on to the office for three or more terms since the 1950s.

Johnson, a Hennepin County commissioner who ran against Dayton in 2014, struggled to gain ground against Walz after surpassing former Gov. Tim Pawlenty in the August primary.

Walz spent six terms representing a Republican-leaning congressional district in southern Minnesota.