WASHINGTON — On a calendar of foreign visitors that includes President Xi Jinping of China and Chancellor Angela Merkel of Germany, the annual visit by the taoiseach of Ireland to mark St. Patrick’s Day should have been a delightful distraction for President Donald Trump.
Mr. Trump, after all, owns a golf resort on the country’s west coast. He has stocked his White House and cabinet with Irish-Americans. And as he never tires of pointing out, he has marched in more St. Patrick’s Day parades in New York City then he cares to remember.
Yet on Thursday, Mr. Trump found himself in a roomful of kelly-green-clad lawmakers in the Capitol for the Friends of Ireland luncheon, being lectured by Enda Kenny, the Irish prime minister, or taoiseach, about the virtues of America’s immigrant legacy and the contributions that immigrants had made to the country.
“There are millions out there who want to play their part for America — if you like, who want to make America great,” he said, shooting Mr. Trump a pointed gaze as he appropriated the president’s campaign slogan. “You heard that before?” he said, to nervous titters.
Mr. Kenny did not refer to Mr. Trump’s travel ban on visitors from six predominantly Muslim countries, which is now tied up in court. He stuck to the issue that has long preoccupied Irish officials: the estimated 50,000 Irish who are living in the United States illegally, and who are at risk of being deported if Mr. Trump delivers on his campaign pledge to round up undocumented immigrants.
“We would like this to be sorted,” Mr. Kenny said, calling for these people to be given a path to citizenship. “It would remove a burden of so many that they could now stand in the light and say, ‘Now I’m free to contribute to America as I know I can.’ That’s what people want.”
“All they want is the opportunity to be free,” he added, choking up momentarily.
It was a somber moment during a ritual that is normally as convivial and rancor-free as any in Washington. The last seven such visits by Mr. Kenny featured good-natured gibes about former Vice President’s Joe Biden Jr.’s long-winded speeches or former President Barack Obama’s habit of toasting the taoiseach with water-filled glasses.
But Mr. Trump’s hard line on immigration has posed a dilemma for Mr. Kenny, who is expected to step down within weeks after six years in office. Mr. Trump is unpopular in Ireland, which has drifted to the left of most Irish-Americans, and there were calls at home for Mr. Kenny to skip the annual visit to Washington. During the presidential campaign, he referred to Mr. Trump’s language as “racist and dangerous.”
Nigel Farage, the British populist leader who is a staunch ally of Mr. Trump, demanded in an interview on Wednesday with RTE, the Irish national broadcaster, that Mr. Kenny apologize to the president for his remarks.
In Washington, Mr. Kenny tried to modulate his criticism, saying it was not directed at Mr. Trump, but at his words. At the lunch Thursday, he straddled a line between being a polite guest and the bearer of a message.
Niall O’Dowd, founder of IrishCentral.com, a news site for Irish-Americans, said, “Feelings run very high about President Trump in Ireland.”
“Kenny has to somehow satisfy a constituency baying for blood back home and demanding he criticize Trump,” he said. “He must also observe the time-honored courtesies and flattery that come with unrestricted access to the president of the United States once a year.”
Fintan O’Toole, an influential columnist at The Irish Times, wrote that Mr. Trump’s immigration policies constituted a “moment of truth” for Ireland. A contingent of Irish-American advisers, he noted, had a strong hand in devising or enforcing the travel ban. The Irish leader, Mr. O’Toole wrote, needed to stand up for all immigrants in the United States, not just Irish ones.
Other advocates for Irish immigrants noted that while Mr. Trump’s travel ban did not affect Ireland, it could eventually be expanded to target different groups.
“When you fire a stone to hit someone from Mexico, you’re hitting someone from Mayo,” said Ciaran Staunton, the co-founder of the Irish Lobby for Immigration Reform, referring to a county in western Ireland.
Still, Mr. Staunton said he opposed efforts to vilify Mr. Trump. A better strategy, he said, would be to lobby him to allow the 20 percent of the 11 million undocumented people in the United States who could easily obtain legal residency to do so without leaving the country.
For his part, Mr. Trump tried to keep things light. But in welcoming Mr. Kenny, he cited what he said was an Irish proverb that speaks to the fickleness of human relations. (The provenance of the phrase quickly came into dispute, with some on social media pointing out its similarity to a stanza in a poem by a Nigerian poet, Albashir Adam Alhassan.)
“Always remember to forget the friends that proved untrue,” Mr. Trump said, “But never forget to remember those who have stuck by you.”