Few Democrats hold local office in the conservative parts of Texas, and Republicans have been eager to replace one who seemed particularly vulnerable: a longtime district attorney in a sparsely populated area of deep red, oil-rich ranches that lie some 250 miles east of El Paso.

They immediately ran into a problem finding a candidate to oppose the incumbent. There were only 16 practicing lawyers in the three counties that make up the deep-red district, including the present Democratic office-holder, Randy Reynolds, who some said was not an effective prosecutor.

But everyone they approached said no.

Desperate for a challenger, they turned to Sarah Stogner, an oil-and-gas lawyer who, on paper, would seem to be an unlikely candidate to boost the Republican Party in what ought to have been one of its strongholds. She has never tried a criminal case. And she’s made her mark in Texas oil law mainly for suing Chevron over environmental damage from abandoned oil wells.

One of her biggest claims to statewide fame was a TikTok video she made in 2022, during her campaign for a seat on the Texas Railroad Commission, the government agency that regulates the oil industry, in which she rode a pump jack nearly topless.

At first, Ms. Stogner, too, said no.

But concerns about crime and potential human trafficking in the area prompted Ms. Stogner to step up. Her entrance as a Republican challenger means that for the first time since 2008 there will be an actual contest for the top prosecutor job in a corner of Texas where fears about crime are often addressed by carrying a sidearm.