Washington CNN  — 

President Donald Trump and Homeland Security Secretary Kirstjen Nielsen got into a lengthy, heated argument during a Cabinet meeting focused on immigration Wednesday, a source with knowledge of the blowup told CNN.

Trump was furious with Nielsen, telling her he didn’t think she was doing enough to secure the border. But Nielsen stood her ground, citing the law in certain instances, the source said.

A separate White House official confirmed that Trump exploded over immigration in front of the Cabinet. The official described the remarks as “angry and heated” but also as fairly typical for Trump on this issue.

The New York Times first reported on the blowup, saying Trump berated Nielsen to the point she told colleagues she was close to resigning after the incident.

Two people told the Times that Nielsen, the Cabinet head who oversees agencies responsible for immigration enforcement and border security, drafted a resignation letter.

Trump went on a “lengthy tirade” before the full Cabinet, the report said, but it added that Nielsen thought the thrust of Trump’s remarks was about her.

A Department of Homeland Security spokesman flatly denied that Nielsen had threatened to resign.

“The @nytimes article alleging that the Secretary drafted a resignation letter yesterday and was close to resigning is false,” the spokesman, Tyler Houlton, tweeted. “The Secretary is hard at work today on the President’s security-focused agenda and supporting the men and women of @DHSgov.”

White House press secretary Sarah Sanders said in reaction to the report, “The President is committed to fixing our broken immigration system and our porous borders. We are a country of laws and the president and his administration will enforce them.”

Nielsen said in a statement that she shares Trump’s frustration about the border, blaming it in part on “congressional inaction.”

“The President is rightly frustrated that existing loopholes and the lack of congressional action have prevented this administration from fully securing the border and protecting the American people. I share his frustration,” Nielsen said. “Border security is the most basic and necessary responsibility of a sovereign nation. These are complex issues and I will continue to direct the Department to do all we can to implement the President’s security-focused agenda.”

The report of Trump’s angry remarks marked at least the second top Cabinet official Trump is said to have berated to the point they nearly quit. The Times reported last year that Trump called Attorney General Jeff Sessions an “idiot” to his face and said he should resign, and a source told CNN last year that Sessions offered to resign amid a series of heated exchanges with Trump.

Nielsen was picked to be secretary after her former boss at the department, John Kelly, was tapped to be Trump’s chief of staff.

Nielsen, who was Kelly’s chief of staff, largely picked up where he left off at the department, including serving as the face of the President’s aggressive immigration agenda. Trump and Kelly have also had an increasingly fraught relationship of late.

Nielsen has served as the primary voice of Trump’s immigration policy and has led the department in pursuing a number of hardline positions to crack down on illegal immigration and cut back on legal immigration. She has defended policies under criticism from Democrats in Congress, including a heated exchange with New Jersey’s Sen. Cory Booker after she said she did not hear the President’s comments in a meeting where he reportedly described immigrants coming from “shithole countries.”

In recent weeks, with increased attention on the southern border and a “caravan” of migrants seeking asylum in the United States, Nielsen has announced that her department will refer any immigrant caught crossing the border illegally for prosecution, even if they may be making a valid asylum claim, which could result in the separation of thousands of parents from their children as they face charges.