PHOENIX — Representative Kyrsten Sinema, a Democrat and former social worker, scored a groundbreaking victory in the race for a Senate seat in Arizona, defeating her Republican opponent after waging a campaign in which she embraced solidly centrist positions.

Ms. Sinema’s victory over Martha McSally, a Republican congresswoman and former Air Force pilot, marks the first Democratic triumph since 1976 in a battle for an open Senate seat in Arizona. Ms. Sinema takes the seat being vacated by Jeff Flake, a Republican who is leaving the Senate after repeated clashes with President Trump.

Ms. Sinema’s victory guarantees the Democrats at least 47 Senate seats. Republicans control 51, with two still undecided: Florida, where there is a recount, and Mississippi, where there is a runoff.

The outcome in Arizona had been too close to call for nearly a week, as large numbers of early and mailed ballots were counted. Ms. Sinema had trailed slightly in initial tallies on Election Day, but later counting put her ahead by a growing margin. On Monday, The Associated Press called the race and Ms. McSally conceded.