The Democrat prevailed after a stream of Islamophobic rhetoric from top Republicans and a turbulent end to his campaign.