Mark Kelly, an astronaut and retired Navy captain, toppled Senator Martha McSally, Republican of Arizona, early Wednesday, flipping a seat vital to Democrats’ effort to wrest control of the Senate.
It was the second time that voters in the traditionally conservative state rejected Ms. McSally, who attached herself to President Trump to buoy her Senate prospects in 2018 and never let go, as they delivered a wholesale rebuke of the president and his allies.
Mr. Kelly, who built a national profile as a gun safety advocate after the shooting of his wife, former Representative Gabrielle Giffords, ran as a pragmatic outsider. At the center of his campaign was the bet that he could appeal to voters in the rapidly changing state — especially the crucial voting blocs Ms. McSally had alienated, including women, younger voters and Latinos, who have become increasingly powerful parts of the electorate in recent years.
His victory, predicted for months in statewide polls, was crucial for Democrats in their bid to take back the Senate. The contest, one of the most expensive and closely watched in the nation, was the first time Arizonans had voted to send two Democrats to represent the Senate since the 1950s, underscoring the shifting demographics and politics of a state once known as a conservative stronghold.
Mr. Kelly leaned hard into his biography on the campaign trail, playing up his work as a NASA space shuttle pilot and retired Navy captain and presenting himself as an independent-minded moderate. He often sidestepped questions about more liberal policies favored by progressives in Congress, keeping a laserlike focus on health care and bludgeoning Ms. McSally over her handling of the pandemic.
Ms. McSally had a compelling story of her own to tell. The first woman to pilot an American warplane in combat, she sued the Bush administration for making her wear an abaya while on duty in Saudi Arabia, and last year spoke out powerfully about how she had been raped by a male superior officer.
But she came into the contest weakened, having lost her first run for Senate in 2018 and prompting Gov. Doug Ducey to appoint her to the seat left vacant by the death of Senator John McCain earlier that year.
In that race, Ms. McSally abandoned the centrist reputation she had cultivated as a congresswoman to prevail in a crowded Republican primary and enthusiastically embraced Mr. Trump, a strategy she maintained in the contest against Mr. Kelly in the special election to serve out the remainder of Mr. McCain’s term.
Though she clung tightly to the president, the feeling was not always mutual. Mr. Trump had repeatedly asked his advisers if her candidacy was adversely affecting his own prospects in Arizona, and at his campaign rallies in the state, instead of bolstering Ms. McSally, he sometimes treated her with disdain. In the final days of the race, during a rally in Goodyear, Mr. Trump told the senator that she had one minute to speak, urging her to be “quick, quick, quick, quick!”
“They don’t want to hear this, Martha,” he said as she rushed to the stage.
There were unforced errors on her part, too. Ms. McSally came under fire in August after jokingly suggesting that supporters “fast a meal” to donate to her campaign. The comment underscored the enormous fund-raising disparity between her campaign and Mr. Kelly’s. He became a fund-raising juggernaut, tapping a web of donors from his time leading a gun control foundation and a swell of online enthusiasm.
But perhaps the most insurmountable chasm Ms. McSally faced was between Arizona’s ruby-red activist base and an increasingly powerful coalition made up of moderates in the suburbs and ethnically diverse voters who chafed at the president’s divisive talk and handling of the pandemic. In a debate with Mr. Kelly in the closing weeks of the race, she declined to say whether she was proud of her support for Mr. Trump.
The extent of the suburban revolt against Mr. Trump was underscored on Tuesday night as Representative David Schweikert, a Republican representing a district on the outskirts of Phoenix, tried to fend off a Democratic challenger in an area long considered safely Republican.