President Trump on Tuesday condemned the shooting of a prominent GOP lawmaker — and announced that the gunman had died after being shot by Capitol police.

The president praised the Capitol cops who took down the gunman, an anti-Republican zealot, and called for prayers and unity.

“This morning a gunman opened fire on members of Congress and their staffs as they were practicing for tomorrow’s annual charity baseball game,” the president said from the White House at 11:30 a.m.

“Authorities are continuing to investigate the crime and the assailant has now died from his injuries. The FBI is leading the investigation and will continue to provide updates as new information becomes available.”

He went on to praise Rep. Steve Scalise (R-Louisiana), who was shot in the attack, which left several others others wounded.

“Steve Scalise, a member of House leadership, was shot and badly wounded and is now in stable condition at the hospital along with two very courageous Capitol police officers,” the president said.

Trump said the officers’ bravery prevented more deaths.

“Many lives would have been lost, if not for the heroic actions of the two Capitol police officers who took down the gunman despite sustaining gunshot wounds during a very, very brutal assault,” he said.

And he praised Scalise as a friend.

“Congressman Scalise is a friend and a very good friend. He’s a patriot and he’s a fighter. He will recover from this assault and, Steve, I want you to know that you have the prayers not only of the entire city behind you, but of an entire nation and, frankly, the entire world.

“America is praying for you.”

Trump also called on Republicans and Democrats to come together.

“We may have our differences, but we do well in times like these to remember that everyone who serves in our nation’s Capitol is here because, above all, they love our country,” he said.

“We can all agree that we are blessed to be Americans and our children can grow up in a nation of safety and peace, and we are strongest when we are unified and when we work together for the common good.”

Rep. Joe Barton (R-Texas) was on the diamond when the shooting broke out.

“Our prayers go out to Steve Scalise and his family and others and the Capitol Hill police who got wounded and our volunteers who got wounded also,” Barton said.

“The heroes are the police officers who attacked the shooter, and in doing so quite probably saved many, many lives.”

He also said he hoped the game between the GOP and Democrats — which raises thousands of dollars for needy children — would still be held Thursday night.

“This is a charity baseball game. We’ve played it for almost 100 years and it’s for a very good cause. I can only speak for myself; I hope we continue the game — in some ways [it’s] what democracy is all about.”

House Speaker Paul Ryan later announced that the game would go on.

Illinois resident James T. Hodgkinson, 66, opened fire at the practice, hitting Scalise, the House majority whip, along with two Capitol Police officers, another law enforcement officer and a staff member for Rep. Roger Williams (R-Texas), witnesses said.

A security detail with the team fired back at the gunman, averting what could have been a far more deadly situation.

Beforehand, the shooter had asked around to make sure that the players were Republicans and not Democrats, witnesses told The Post.

A Facebook page belonging to a James T. Hodgkinson bears several photos of former presidential candidate Bernie Sanders and President Franklin D. Roosevelt, as well as anti-Trump rants.

On March 22, Hodgkinson wrote in a post, “Trump is a Traitor. Trump Has Destroyed Our Democracy. It’s Time to Destroy Trump & Co.” and linked to a petition calling for the removal of the president.