WASHINGTON — President Trump, who last year denounced the Persian Gulf state of Qatar as a “funder of terrorism” and backed its rivals in a contentious regional feud, welcomed its monarch to the Oval Office on Tuesday and portrayed him as a partner in the fight against extremists.

The friendly visit represented a remarkable turnaround for a president who had once portrayed Qatar as part of the problem. But it reflected the success of an intense and expensive effort by Qatar and its paid lobbyists, including a top fund-raiser for Mr. Trump, to change its image in Washington and present it as a partner with the United States in the war on terrorism.

“We’re making sure that terrorism funding is stopped in the countries that we are really related to, because I feel related,” Mr. Trump said as he hosted Emir Tamim bin Hamad Al-Thani of Qatar. “But those countries are stopping the funding of terrorism, and that includes U.A.E. and it includes Saudi Arabia, it includes Qatar and others. A lot of countries were funding terrorism and we’re stopping it.”

Turning to the emir, Mr. Trump added, “You’ve now become a very big advocate, and we appreciate that.”