BISMARCK, N.D. (AP) — In both the governor's race and a farming referendum, North Dakota primary voters turned aside the Republican establishment.

Former Microsoft executive Doug Burgum pulled off something of a surprise win Tuesday in the GOP primary for the state's top job. He defeated longtime Attorney General Wayne Stenehjem — the endorsed candidate of the state's GOP convention.

And voters overwhelmingly rejected a new law passed by the Republican-controlled Legislature that would have exempted pork and dairy operations from a Depression-era ban on corporate farming. Eight other states have laws restricting corporate farming, though all allow exemptions for some livestock operations.

The GOP battle between Burgum and Stenehjem featured a spirited debate about which candidate was better suited to revive a state economy slumping due to depressed oil and crop prices.