Illinois Gov. Bruce Rauner (R) addresses a crowd on Tuesday. (Nam Y. Huh/AP)

Centrist incumbents in both parties survived high-profile primaries in Illinois on Tuesday, edging out restive liberal and conservative challengers in contests that served as tests of the establishment’s strength against insurgents.

Democratic Rep. Daniel Lipinski, a seven-term congressman often at odds with his party on social issues, narrowly defeated liberal activist Marie Newman, a first-time candidate who described him as a “Trump Democrat.”

Republican Gov. Bruce Rauner also faced a tough challenge but ultimately beat Jeanne Ives, a conservative state lawmaker who accused him of betraying his political base on abortion, gay rights and spending.

Coming after primaries in Texas and a special election in Pennsylvania that caused some upheaval, the contests in Illinois gave at least a temporary boost to the establishment. But the narrow wins also exposed the danger traditional candidates face in what has been a turbulent election year.

Lipinski’s district, which stretches from Chicago to the southwest suburbs, is expected to remain in Democratic hands in November. After no credible Republican filed to run, the only challenger on the ballot will be Art Jones, a neo-Nazi activist denounced by the GOP.

But Rauner, a first-term governor, is expected to face a serious challenge from billionaire J.B. Pritzker, who secured the Democratic nomination.

With 97 percent of the vote tallied Wednesday morning, Rauner led Ives, a pro-Trump lawmaker, by about three percentage points, a margin Democrats sought to seize on in attacks. The Democratic Governors Association branded him “the nation’s most vulnerable governor” and released an online video criticizing his management of the state.

The Republican Governors Association, meanwhile, labeled Pritzker a “self-serving Illinois political insider.”

“To those of you around the state who wanted to send me a message, let me be clear: I have heard you,” Rauner told supporters in his victory speech.

Meanwhile, fewer than 1,600 votes separated Lipinski from Newman. The Associated Press has declared Lipinski the winner.

Rep. Daniel Lipinski (D) speaks on Capitol Hill in Washington. (Pablo Martinez Monsivais/AP)

Lipinski, the policy chairman of the conservative Blue Dog Democrats, has built a moderate record, opposing the Affordable Care Act because of his antiabortion stance. He also voted for religious freedom bills that are viewed as making it easier for private businesses to discriminate against gay customers.

Local Democrats and labor unions consistently endorsed Lipinski, citing his votes against trade deals and his ability to bring transportation money back to the district.

Despite the numbers, Newman’s backers were defiant on Tuesday night, saying that they’d gotten behind her to send a message. And Newman said her campaign had had an effect.

“We have moved him on immigration, we have moved him on health care. . . . So let’s be clear, the fight is not over, and it is not done,” she told supporters, referring to Lipinski.

Newman, who was the Illinois spokeswoman for the gun-control group Moms Demand Action, received endorsements from NARAL Pro-Choice America, MoveOn, Emily’s List and two of Lipinski’s more liberal Illinois colleagues, Reps. Jan Schakowsky (D) and Luis V. Gutiérrez (D).

Rauner, a former private-equity executive, provoked the conservative right in September when he signed a bill expanding abortion coverage for women on Medicaid. He also engaged in a long budget standoff with the state legislature that left Illinois $15 billion behind on its bills and triggered multiple downgrades that pushed the state’s credit rating almost to junk status.

Rauner had put $50 million of his own money into his campaign, much of it on ads that blamed Illinois House Speaker Michael J. Madigan (D) for the state’s problems. Pritzker spent more than $60 million to win his race.

Pritzker, whom Democratic leaders viewed early on as the strongest challenger to the wealthy Rauner, struggled after the Chicago Tribune released tapes of conversations between him and disgraced former governor Rod Blagojevich (D) from an FBI wiretap.

In the crowded Democratic primary for attorney general, state Sen. Kwame Raoul defeated Pat Quinn, a former governor.

The party was also watching a scrum in the 6th Congressional District, which Democrat Hillary Clinton won by seven points in the 2016 presidential election. Seven Democrats are battling to challenge Rep. Peter J. Roskam (R) there, with scientist Kelly Mazeski leading in a race that was still too close to call Wednesday morning.

Democrat Betsy Dirksen Londrigan was projected to win in the race against Rep. Rodney Davis (R), in a central Illinois district evenly divided between the parties.