ATLANTA — President Trump received a thunderous welcome from thousands of gun lovers as he appeared here on Friday at the National Rifle Association’s annual convention to thank the group for its unwavering support of his presidential campaign.

A supporter of restrictions on guns before he entered politics, Mr. Trump became a fierce champion of gun rights during his bid for the White House, earning early backing — and $30 million in campaign support — from the powerful lobbying group.

“Only one candidate in the general election came to speak to you, and that candidate is now the president of the United States, standing before you,” Mr. Trump said. “You came through for me, and I am going to come through for you.”

The president was received as a hero, in part for successfully installing a conservative Supreme Court justice, Neil M. Gorsuch, who is seen as a likely protector of the Second Amendment. Mr. Trump in turn treated the gun convention like a political rally, joyfully recalling his election victory and mocking the journalists and Democrats who were confident that he would lose.