HARRISBURG, Pa. (AP) — Four-term U.S. Rep. Lou Barletta, a staunch supporter of President Donald Trump who first got national notice as a small-city mayor for his attempted crackdown on illegal immigration, on Tuesday won the Republican nomination for U.S. Senate in Pennsylvania.

Barletta had paid little attention to his Republican rival, state Rep. Jim Christiana, during the primary campaign. Instead, he focused his attacks on the candidate he hopes to unseat in the fall, two-term Democratic Sen. Bob Casey.

At his election night party in his hometown of Hazleton, Barletta appealed to the voters who helped Trump win the state in 2016's presidential election. He said Casey has tried to "resist, reject and obstruct every step this president has taken."

"Bob Casey has moved so far left he doesn't really represent Pennsylvania anymore," Barletta said.

The Pennsylvania Democratic Party singled out Barletta's tough stance on illegal immigration, saying Barletta "has built his long political career on spreading fear, dividing communities and scapegoating immigrants."

It also said he has backed Republican House Speaker Paul Ryan's agenda of slashing taxes for corporations and the wealthy while attacking Medicare and Social Security and trying to repeal former President Barack Obama's signature health care law.

"But most of all, Barletta has made it clear that if elected to the Senate, he would put Donald Trump's interests ahead of the people of Pennsylvania," the party said.

Barletta is a favorite of Trump, whom Barletta endorsed in 2016. Trump asked Barletta to run for Senate, and the president is expected to visit Pennsylvania to campaign for him.

Casey, who was unopposed for the Democratic nomination, has opposed Trump's Supreme Court pick, many of his highest-profile nominees and the GOP tax-cutting law while emerging as an ardent Trump critic.

Casey is among 10 Democratic senators seeking re-election this year in states won by Trump, making Casey a target for Republicans.

Trump edged Democrat Hillary Clinton by less than 1 percentage point in Pennsylvania in 2016's presidential election. Republicans control the Senate, 51-49, and defeating Casey would give Republicans one more pro-Trump vote to help advance the president's agenda.

Still, defeating Casey in November's election is a tall order.

Casey, the son of a late former governor, has strong name recognition and has won five statewide elections. He also has a huge cash advantage, with about $10 million in the bank at the end of April, compared with Barletta's $1.3 million.

Casey, 58, is popular with labor unions and backed Obama's signature policies.

Barletta, 62, won his House seat during the Republican midterm wave of 2010, catapulted by the attention he received while mayor of Hazleton for attempting to use local laws to crack down on immigrants in the city who had entered the country illegally.