Democrats agreed to let a Republican take the speakership of the Minnesota House after a weekslong fight over control of the chamber.