Steve King, the Republican incumbent, defeated his opponent, J.D. Scholten, a Democrat and former professional baseball player. Few forecasters expected a competitive race in this normally deep red district in rural northwest Iowa, but Mr. King’s hardline anti-immigrant views and inflammatory statements during the campaign drew criticism from across the political spectrum.