President Donald Trump finally took himself off the sidelines in the key Arizona Senate race on Wednesday morning.

After Rep. Martha McSally easily won Tuesday's bruising Republican Senate primary, the president threw his support behind her in her bid to win outgoing GOP Sen. Jeff Flake's seat. In a tweet Wednesday, Trump called the second-term representative and former fighter pilot an "extraordinary woman" who has "my total and complete Endorsement!"

Trump tweet: Martha McSally is an extraordinary woman. She was a very talented fighter jet pilot and is now a highly respected member of Congress. She is Strong on Crime, the Border and our under siege 2nd Amendment. Loves our Military and our Vets. Has my total and complete Endorsement!

Trump took longer to back his party's leading Senate candidate in Arizona than he did in other pivotal Senate races, such as those in Florida, Missouri or North Dakota. But he quickly backed McSally after her victory, a signal that the president or his allies believe she could use support from Arizona's conservative base if she is going to prevail in one of the Senate battlegrounds most favorable to Democrats this year.

McSally previously associated herself with the House GOP's more centrist wing, supporting compromise on policies such as immigration, before proudly tying herself to Trump during the GOP primary. The representative and her opponents, former state lawmaker Kelli Ward and ex-Maricopa County Sheriff Joe Arpaio, scrambled to cast themselves as the staunchest ally of the president in order to excite Republican primary voters.

McSally's record and the politics of her opponents may have contributed to Trump's decision to sit out the primary. The representative notably called Trump's "Access Hollywood" comments about groping women without their consent "disgusting" when the remarks surfaced in 2016. Still, Trump has endorsed other candidates who disavowed him following those comments.

In addition, her primary opponents more closely emulated Trump's nationalist, off-the-cuff politics, which complicated his endorsement decision. Ward and Arpaio — whom Trump pardoned for a criminal contempt conviction related to his treatment of undocumented immigrants — appeared to split the state's ultraconservative base as McSally coasted with more than 50 percent of Tuesday's vote.

Ward, who unsuccessfully challenged the late Sen. John McCain in 2016, tweeted a widely criticized joke that "political correctness is like a cancer" on Monday, a day before the election and two days after McCain died of brain cancer. She also apologized for saying the McCain family had timed Friday's announcement of his end of treatment in order to hurt her candidacy. Trump also frequently criticized McCain this year even as he was away from Washington receiving treatment, and the White House faced backlash for defending a staffer who joked about McCain's failing health.

McSally's past efforts to stand with the GOP's more moderate wing make political sense: Her House district is ideologically split and she hopes to win a Senate seat in a state that Trump won by fewer than 4 percentage points. Now, she faces a balancing act of trying to simultaneously appeal to moderate voters in the state and boost turnout among staunch Republican voters loyal to Trump.

It is unclear now which strategy will work best as McSally tries to defeat Democratic Rep. Kyrsten Sinema, who won her Democratic primary on Tuesday. During Trump's presidency, Arizona's two Republican senators — McCain and Flake — criticized Trump much more often than their Republican colleagues. But Flake is highly unpopular in the state.

The race's outcome has major stakes for Trump and his agenda. The GOP currently has a narrow 51-49 seat majority in the Senate.

Trump has frequently complained that he needs more Republican senators to enact his agenda, after the GOP's effort to repeal the Affordable Care Act failed by one vote in the chamber last year. McCain, who had just returned to Washington after surgery for brain cancer, cast one of the votes to sink his party's legislation.

Democrats face a difficult Senate landscape this year, as the party's senators and independents who caucus with them defend 26 seats. Arizona is one of only nine Republican Senate seats up for grabs, and perhaps the minority party's best chance of gaining ground.

Trump has already campaigned for several Republicans trying to unseat Democratic Senate incumbents in states such as Indiana, West Virginia and North Dakota.