PHOENIX — As Democrats lashed into one another on the debate stage, President Donald Trump took some swipes of his own at a rally aimed at counterprogramming the Democrats' big night from a state that could be up for grabs in November.

The president took the stage about 20 minutes after the Democratic debate began and clearly had the event on his mind.

"I hear he is getting pounded tonight," Trump said of former New York Mayor Mike Bloomberg, who drew some of the most bruising attacks from his Democratic rivals. Later in the rally, speaking of Sen. Bernie Sanders, I-Vt., Trump asked the crowd: "How's he doing tonight?"

He continued to try to fuel division between Sanders' supporters and the establishment wing of the party. "The DNC is going to take it away from Bernie again," he said. "But that's OK, because we don't care who the hell it is. We are going to win."

Trump also brought his Twitter attacks on Bloomberg over the past week to life, mocking the former mayor's height and downplaying the effect of his campaign spending.

"He spent $500 million so far, and I think he has 15 points," Trump said while downplaying the prospect, or effect, of being outspent by the billionaire: "My father would teach me if you can spend less and win, that's better than spending a lot."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Trump has been seeking to steal the spotlight from Democrats, holding a rally during the January debate and putting on events in Iowa and New Hampshire days before voters cast ballots in those states. He'll hold another rally in Nevada on Friday, the day before the state's caucuses.

But Trump's visit to Arizona also has a direct link to his re-election efforts.

No Democrat has won Arizona's 11 electoral votes since Bill Clinton in 1996, but it has a growing Hispanic population, and Democrats view the once solidly red state as within reach. Trump beat Hillary Clinton in Arizona by 4 percentage points in 2016, but his approval rating in the state has since sunk by 21 percentage points, to 49 percent in January, according to Morning Consult polling.

While claiming his internal poll numbers showed him beating the slate of Democratic contenders and calling unfavorable numbers "fake polls," Trump blamed the news media for his depressed approval numbers.

Along with firing up his base and garnering local media coverage, the rally will also provide the campaign with tens of thousands of email addresses and cellphone numbers from those who signed up for tickets — information the campaign can use to mine for donors and volunteers to get better insights into the type of voter who is supporting Trump as it looks to find untapped groups of new supporters.

Trump's visit was also aimed to give a boost to Sen. Martha McSally, R-Ariz., who stood by Trump during his impeachment and has gone from a detractor to a staunch defender. Trump returned the favor Wednesday, giving her a ringing endorsement as he called her up onstage.

"She helped me so much during the impeachment hoax. She didn't wobble one bit," Trump told the crowd. He said McSally "is tough as hell, and that is what we need."

McSally, a retired Air Force colonel, is in a tight contest in a special election with former astronaut Mark Kelly, the husband of former Rep. Gabrielle Giffords, D-Ariz.

"Her opponent, a guy named Mark Kelly, even the Democrats don't like him much. He wants to raise your taxes, open your borders, give away free health care to illegal immigrants, and he wants to obliterate your Second Amendment," Trump said.

Download the NBC News app for breaking news and politics

During the 2018 midterm elections, four Democrats won statewide offices, including Kyrsten Sinema, whose victory over McSally made her the first Democrat to win a Senate seat from Arizona since 1988. McSally was then appointed months later to fill the state's other Senate seat, which was vacated by Republican Jon Kyl, who had held it on an interim basis following the death of Sen. John McCain.

After lashing out at his Justice Department over the past two weeks over its handling of the sentencing of his longtime political adviser Roger Stone, Trump lobbed only a passing attack Wednesday — although a stinging one.

"There are a lot of dishonest slimeballs out there — dishonest scum, dirty cops," Trump said. "A lot of dirty cops."