In turn, he showed restraint and discipline in talking about the president and was quick to support Mr. Trump’s proposed tariffs on steel and aluminum imports. He did not respond to the president’s mockery, and on Wednesday morning, refused to engage when he was asked on CNN to comment about Mr. Trump’s remarks.
A full list of elections for the House and Senate, including which races matter most for congressional control.
“You call it a red district,” Mr. Lamb said on CNN. “I call it western Pennsylvania. We worked extremely hard to get out and campaign in person over every square inch of this district. And I think just through talking to people, looking them in the eye, figuring out what the issues are for them and trying to come out with solutions, we seemed to have reached a lot of people. We saw huge turnout on both sides which is great. People around here are engaged.”
Mr. Lamb also said he thought voters were weary of pettiness and name calling.
“There was a lot of foolishness in this election and cartoonish campaigning,” he said. “By the time of the president’s visit last weekend, people were tired of that entire approach. I had people, especially elderly people, come up to me and say, I hate those ads against you. It’s not right. It’s not worthy of us. I think there is a little bit of burnout on that type of campaign before the president ever got here.”
Mr. Lamb built his coalition from many disparate parts. He bridged the divide between labor union leaders and their members. “He married the union leaders and rank-and-file for the first time in two decades,” said G. Terry Madonna, a professor at Franklin and Marshall College who has conducted polls in Pennsylvania for more than three decades.
He also focused heavily on local issues and mostly avoided getting into a fight with his Republican opponent, Rick Saccone, over Mr. Trump.
“He decided early on he would not turn this into a national election,” Mr. Madonna said. “It was a local election. Number two, he did events, but more important, he knocked on the door, put the yard sign up, emphasizing his personal connection with people, something Saccone did not do.”
He added, “And also, he was like, ‘Donald who? Who’s that guy?’”
Though the race was Mr. Lamb’s first attempt at public office, politics is part of his family pedigree. His grandfather, Thomas Lamb, was the Democratic leader of the State Senate in the 1970s and served in the administration of Gov. Robert P. Casey.
Michael Lamb, his uncle, is the controller for the city of Pittsburgh and an avid supporter. His younger brother, Coleman Lamb, is helping out as well, on loan from his day job as press secretary for a New York congresswoman.
Mr. Lamb leaned hard on his military background — he served as a prosecutor in the Marine Corps and was stationed in Okinawa while on active duty — and his support for gun rights, beginning with his first commercial.
That same ad also featured a picture of him at a gun range, noting that he “still loves to shoot.” These were acts of political inoculation: Mr. Lamb was sending a message to the district’s conservative-leaning voters that he was his own person.
He also effectively neutralized Republican attempts to label him a liberal in the mold of the House Democratic leader, Representative Nancy Pelosi, by saying that he would not vote for her in a leadership election. Republicans, who poured in millions of dollars in ads against Mr. Lamb, tried to paint him as a slavish follower of the California Democrat. He countered with a commercial noting that his opposition to her had been reported on the front page of a local newspaper.
Mr. Lamb had another résumé-enhancing line to offer voters: federal prosecutor. After clerking for a federal judge in New York, he did a stint as an assistant United States attorney in Pittsburgh, prosecuting a range of cases that gave him a law-and-order credential.
But his time in the Justice Department during the Obama administration also provided Republicans with some fodder. In one ad, the National Republican Congressional Committee noted that Mr. Lamb had reached a plea bargain with a drug kingpin, a potentially damaging line of attack in a region ravaged by opioids.
Like the other attacks Republicans hurled at him, it ultimately proved ineffective.