WASHINGTON — President Donald Trump on Friday accused Democrats and the U.S. intelligence community of attempting a "coup" in the form of special counsel Robert Mueller's Russia investigation and said he didn't "need a gun" to fend it off.

"They tried for a coup, it didn't work out so well. And I didn't need a gun for that one, did I?" Trump told the crowd of gun-rights advocates at the National Rifle Association’s annual meeting in Indianapolis on Friday. "All was taking place at the highest levels in Washington, D.C. You've been watching, you've been seeing.”

"Spying, surveillance. Trying for an overthrow," Trump continued. "And we caught them, we caught them. Who would have thought in our country?"

During his speech Trump also announced he would remove the U.S. from the Arms Trade Treaty, which he described as "badly misguided" and promised to never allow foreign bureaucrats to "trample on your Second Amendment freedoms."

Trump also touched on issues of immigration and the border wall during the event. He promised the crowd he would have "over 400 miles of border wall built by the end of next year" and lamented that immigration laws could be changed in "15 minutes" if it were not for Democrats in Congress.

"Dealing with these people is very, very difficult if you haven’t noticed. Any other politician would have given up a long time ago," Trump said of Democratic lawmakers.

Trump also celebrated his appointments of federal judges, stating that "next week we will confirm our 100th federal judge," adding that he expects to have the second highest percentage of judges confirmed, other than George Washington. "He gets 100 percent."

Trump also appeared to have his 2020 re-election on his mind. He attacked Democratic presidential candidates, calling them "maniacs."

"We believe in the rule of law, and we will always protect and defend the Constitution of the United States," Trump said. "There are some people who are running right now and I don’t think they have that No. 1 on their list."

"You better get ready to vote," Trump added, noting that the election was still well over a year away.

The NRA spent more than it ever had on an election in 2016, shelling out over $36 million to help Trump. Friday was Trump’s third consecutive year addressing the NRA gathering as president.

The NRA is known as a fierce lobbying presence in Washington that critics say is unafraid to use scare tactics and fearmongering to achieve policy goals. But it has faced issues in the past few months.

The group is entangled in several lawsuits and has struggled to raise enough money to fully fund its operations. They have also seen some of their recent efforts fail: The House this month voted to approve an updated Violence Against Women Act that banned those convicted of domestic abuse from purchasing a gun.

Although the NRA has overwhelmingly supported Trump, the president has not always been a reliable ally to the group’s policy goals.

After the mass shooting at a high school in Parkland, Florida, in 2018, Trump accused some lawmakers of being too "afraid" of the NRA and said he would ban bump stocks — a suggestion he first made after the mass shooting in Las Vegas in 2017 in which 58 people were shot. More than a year after the Parkland shooting, the bump stock ban took effect, though gun rights groups have appealed the ban in court.