Pat Toomey, one of the most endangered Senate Republicans in the country, appears Tuesday to have survived a major scare from Democrat Katie McGinty, ensuring his party will retain control of the chamber.

Toomey, a former representative from Lehigh Valley who won his seat during the Republican wave in 2010, always figured to be vulnerable during a presidential election year when turnout by Democratic voters typically spikes in Pennsylvania. Polls indicated a close race that could go down to the wire.

Toomey also caused himself plenty of headache with his bumbled handling of Donald Trump’s controversial statements. He appeared to try to have it both ways and ended up making few voters happy.

McGinty, who lost a race for the Democratic nomination for governor in 2010, ran on a platform of support for stricter gun control, abortion rights, and respect for same-sex marriage. She previously worked as an environmental officials at the state and federal levels.

Toomey has been a consistent advocate for lower taxes and smaller government but departed from conservative orthodoxy with his attempt to fashion a bipartisan compromise on expanding background checks for gun purchases.