President Trump's meeting with House Republicans to discuss immigration legislation briefly went awry Tuesday after the president mocked Rep. Mark Sanford over a primary election loss.

Two sources in the meeting room told The Associated Press that Trump joked: "I want to congratulate Mark on a great race."

A senior House Republican who is a Trump supporter told Fox News that the president's comment was "unnecessary" and "poor form." Another senior GOP lawmaker called it a "low blow."

Another GOP member told Fox News the room got "pretty quiet" after the remark and some attendees booed in a low tone of voice.

Sanford, a former South Carolina governor and frequent Trump critic, was defeated by state Rep. Katie Arrington in the June 12 primary. Hours before the polls closed, Trump endorsed Arrington on Twitter and joked that Sanford was "better off in Argentina" -- a reference to a sex scandal that overshadowed Sanford's tenure as governor.

Sanford blamed his defeat on Trump, saying support for the president is becoming a litmus test in GOP primaries.

"It's a very tribal environment right now," he said at the time.

Politico reported that Sanford was not at the meeting because he was unable to fly to Washington from South Carolina due to poor weather.

Fox News' Chad Pergram, Anne Ball and The Associated Press contributed to this report.