Debbie Lesko, right, won a special congressional election in Arizona on Tuesday night to keep the seat in Republican control. She was joined by Jan Brewer, a former governor of the state.

WASHINGTON — The former Arizona state senator Debbie Lesko fended off an unusually strong Democratic challenge to win a special congressional election on Tuesday, according to The Associated Press, demonstrating the resilience of the Republican base but also the eagerness of liberals to compete in even the most heavily conservative districts.

Lifted by more than $1 million in outside spending from Republican groups determined to avoid another electoral embarrassment, Ms. Lesko defeated Hiral Tipirneni, a physician and first-time candidate, in a district President Trump carried by over 20 points.

With nearly all of the early ballots counted Tuesday night, which were expected to make up the bulk of the vote, Ms. Lesko was ahead by nearly six percentage points.

Ms. Lesko was helped by an aggressive intervention from Republican leaders that included a wave of robocalls from Mr. Trump and fund-raisers hosted by House Speaker Paul D. Ryan and Representative Kevin McCarthy of California, the majority leader.

Republicans Lost Support in Every Special Election Since Trump Became President

April 25, 2018

Republican officials described their efforts as precautionary, a nod toward the party’s humiliating special election losses in Alabama and Pennsylvania and an acknowledgment that they must fortify their defenses in even the reddest of districts.

The Phoenix-area seat for the Eighth Congressional District, a haven for sunshine-seeking retirees from the Midwest, is so reliably Republican that Democrats did not even field a candidate in the last two elections.

But after the previous representative, Trent Franks, resigned following revelations he had offered $5 million to an aide in exchange for carrying his child, Arizona Democrats rallied to Ms. Tipirneni. She outraised Ms. Lesko in…