Mark Kelly, the former astronaut and gun-control activist who is married to Gabrielle Giffords, announced on Tuesday that he would run for Senate in Arizona, challenging appointed Senator Martha McSally and intensifying the Democratic threat to Republicans’ narrow control of the chamber.

Mr. Kelly’s entry sets up a possible general election between two combat veterans in a swiftly changing state, and may elevate Arizona further as a 2020 battleground. Both parties already view Arizona as a swing state in the presidential race and in 2018 Democrats won a Senate race there for the first time in decades.

Ms. McSally, an Air Force veteran, was narrowly defeated in a statewide race last year by Senator Kyrsten Sinema. Ms. McSally joined the Senate anyway a few months later, appointed to fill the vacancy left by John McCain’s death after a placeholder appointee, Jon Kyl, resigned.

[Make sense of the people, issues and ideas shaping American politics with our newsletter.]

Mr. Kelly, 54, unveiled his campaign in an online video highlighting his experience as an astronaut and Navy pilot. Ms. Giffords, a former member of Congress who was shot and nearly killed by a deranged gunman in 2011, appeared beside him in the message.