President Trump began berating Homeland Security Secretary Kirstjen Nielsen in the Oval Office earlier this spring, according to administration officials, griping about her performance and blaming her for a surge in illegal border crossings.

White House Chief of Staff John F. Kelly, who installed her in the job, jumped in to defend her.

The two men then sparred over Nielsen as she silently watched. At one point, Trump noted the border numbers were lower under Kelly and wondered aloud why Nielsen could not perform as well, according to these officials, who spoke on the condition of anonymity to describe the private meeting.

As illegal crossings are once more on the rise and Trump hears a cascade of criticism from conservative allies, Nielsen finds herself on the receiving end of the president’s visceral anger about immigration. He sees the issue as the reason he won the presidency and a key to his politicking ahead of the midterm elections.

The president has chastised Nielsen on several occasions this spring, including in a much publicized meeting this month when he attacked her in front of the entire Cabinet. He has grown furious because his administration has made little progress building the promised border wall, and his most ardent supporters have blamed Nielsen for not doing more to halt the caravan of Central American migrants whose advance Trump saw as a personal challenge.

He has also seen her as a proxy for Kelly, whose relationship with the president has frayed in recent months. Trump has decided, according to several aides, that Nielsen is a George W. Bush kind of Republican — the worst, in his view.

Nielsen has complained that it is almost an impossible task working for Trump, according to administration officials and others familiar with her thinking, and that he doesn’t understand the nuances of immigration law.

It remains unclear, according to several people familiar with the situation, how much longer the relationship can last, but the strains illustrate the difficulty faced by Trump subordinates who are tasked with delivering policy solutions to match his most soaring promises.

“The president has a very rudimentary understanding of what the border is all about and how you secure it,” said a former Department of Homeland Security staffer who worked closely with Nielsen. “And she’s also not one of the border fire-eaters that have his ear right now.

“She’s in an impossible, no-win situation.”

Tensions between the two could soon flare again — the Border Patrol’s May arrest numbers are due to be released early next month, and immigration hawks, including the president, now treat them as a kind of barometer for Nielsen’s performance.

“Secretary Nielsen is vigorously advancing the president’s agenda to secure this nation’s borders against uncontrolled migration, drugs, gangs, terrorism, crime and the theft of taxpayer dollars and American jobs,” White House senior policy adviser Stephen Miller said in a statement. “She knows the threat, understands the threat, and is undertaking bold action to confront it head-on.”

Tyler Houlton, a DHS spokesman, said Trump and Nielsen are “on the same page,” adding that “any accusations to the contrary are simply false.”

'He wants . . . shock and awe'

Nielsen brings a lawyerly, technocratic approach to an issue that animates the president like no other, with a passion dyed into the blood-red MAGA caps of his supporters.

The night before Trump delivered his first speech to Congress in February 2017, he huddled with senior adviser Jared Kushner and Miller in the Oval Office to talk immigration. The president reluctantly agreed with suggestions that he strike a gentler tone on immigration in the speech.

Trump reminded them the crowds loved his rhetoric on immigrants along the campaign trail. Acting as if he were at a rally, he recited a few made-up Hispanic names and described potential crimes they could have committed, such as rape or murder. Then, he said, the crowds would roar when the criminals were thrown out of the country — as they did when he highlighted crimes by illegal immigrants at his rallies, according to a person present for the exchange and another briefed on it later. Miller and Kushner laughed.

A senior White House official said that while the president did discuss the “crowd enthusiasm for crackdowns on criminal aliens,” the official disputed that Trump used Hispanic names to illustrate the point.

Around the same time, Nielsen was complaining to colleagues — and her then-boss, DHS secretary Kelly — about how the administration botched its travel ban. She panned Trump’s statement about the border wall, saying it was unlikely to ever be built. Kelly agreed. The two sometimes joked about it.

In early 2017, Nielsen told at least two colleagues that the presi­dent’s rhetoric made it more difficult to run the agency.

Now, five months into her tenure as homeland security secretary, the measures Nielsen has implemented — separating families, boosting arrests, increasing prosecutions — have made her a villain to many Democrats and immigrant rights’ groups.

But the actions have not delivered the immediate results the president demands. In April, the number of illegal border crossers arrested by U.S. agents topped 50,000 for the second consecutive month. The increase has stripped the president of one of his proudest accomplishments — the sharp drop in illegal migration in the months immediately following his 2016 win.

Trump has been in no mood to hear that migration patterns have returned to historic, seasonal norms this spring, a trend occurring in part because the U.S. economy is buzzing and farms, factories and businesses are desperate for workers.

Instead, Trump has fumed at Nielsen, telling her to “close the border” and growing impatient at her explanations of why that’s not possible. He has also blamed her, at times, for not securing enough money to finish the border wall — even though she was not party to the spending deal struck by senior White House aides and that the president signed, current and former administration officials said.

Allies of Nielsen note that some of the president’s gripes are with immigration judges who cannot process people quickly enough, caravans that cannot be immediately stopped by DHS because of asylum laws and international agreements.

In fact, Trump has grown more agitated when she has tried on several occasions to describe why she cannot do what he wants — and what laws and budget mandates might prevent it.

Mark Krikorian, head of the Center for Immigration Studies, a Washington think tank whose ideas about the benefits of restricting immigration have broad influence in the administration, said Trump wants Nielsen to deliver a crackdown that looks like “the Iraq War.”

“He wants to do shock and awe,” Krikorian said. “He doesn’t realize this is World War I. It’s trench warfare.”

A Kelly person

Calling Nielsen “a Bush person” is a label that casts doubt on her loyalty to the president and his immigration agenda. But Nielsen’s real problem, current and former colleagues say, is that she is a Kelly person — and that she has few allies in the White House other than the diminished chief of staff.

“It’s the same thing we’ve seen happen with General Kelly. My suspicion is there are rogue people in the West Wing and former officials who got pushed out who are running disinformation campaigns,” said Blain Rethmeier, an ally of both.

Soon after Kelly became White House chief of staff, he presented Trump with only Nielsen’s name to replace him at DHS, according to three current and former White House officials. He pushed Trump repeatedly to pick Nielsen — even though the president had barely spent time with her and she was a polarizing figure inside the White House. Others pushed candidates such as Kansas Secretary of State Kris Kobach, an immigration hard-liner whom the president liked but was told could not be confirmed.

Trump brought Kelly in to tame a wild West Wing in July 2017. Kelly asked Nielsen to be his deputy and trusted enforcer, and she quickly grated on White House staffers who viewed her as a humorless scold who did not communicate with aides. For her part, Nielsen told others she could not believe how disorganized and chaotic the place was. Several White House officials said her only ally in the building was Kelly.

She stayed away from Trump, “maybe visiting the Oval Office five times,” according to a former senior administration official. Other aides frequently bad-mouthed her to the president.

Soon after Trump picked her to lead DHS in October, he came to regret it, threatening to renege on her nomination. In an Oval Office meeting last fall, Trump complained about Nielsen to Kelly even as she sat nearby, officials familiar with the meeting said.

“Nobody likes her,” he said, telling Kelly he had heard from friends, West Wing aides and TV personalities. He then asked why Kelly had pushed so hard for her nomination and whether he had to stick with the choice, according to the officials.

Kelly defended Nielsen, citing her work ethic and knowledge of the agency. Trump decided to move forward with her nomination.

Many senior staffers at DHS were stunned when Nielsen was appointed to lead the department. She had never led a large organization, let alone one as unwieldy as DHS.

Nielsen, 46, worked as a DHS staffer and adviser under George W. Bush, then spent the Obama years remaking herself as a cyber­security expert. Her high-level management experience was thin.

When Trump was elected in 2016, Nielsen was running Sunesis Consulting, a firm whose online profile listed her as its lone employee. The company’s business address was a condo in Alexandria. The firm’s phone number, still visible online, is Nielsen’s personal cellphone.

Nielsen quickly impressed ­Kelly with her breadth of knowledge, discipline and willingness to work hard, former colleagues said. When Nielsen fell ill that winter with a respiratory infection, she continued putting in long hours, despite coughing so hard that she cracked a rib.

The Marine general valued her toughness and soldierly sacrifice. Kelly’s wife called her “a pit bull.”

She has struggled to win support from senior officials at the DHS agencies responsible for delivering an immigration crackdown. One high-ranking DHS official called her leadership style “insular and insecure,” saying she has made few allies outside a small circle of trusted advisers, including DHS Chief of Staff Chad Wolf and Jonathan Hoffman, her communications director. Aides say a number of DHS employees have been offended because she micromanages and even grows testy with staff over small matters, such as a misspelling in an email.

During immigration negotiations with congressional leaders this year, Nielsen did not invite the heads of Immigration and Customs Enforcement, U.S. Customs and Border Protection and U.S. Citizenship and Immigration Services (CIS), all officials with extensive career experience. They viewed it as a slight, according to current and former DHS officials, and when the immigration negotiations failed to produce a deal, it meant even more of the blame fell on Nielsen.

Nielsen has faced the same staffing shortfalls that have afflicted other agencies under Trump, but in the past two months, DHS has filled 10 senior staff-level positions, an official at the agency said.

Still, Nielsen has few friends in the White House besides Kelly and has clashed with Miller, the influential immigration adviser.

When Trump’s advisers were writing a report on terrorism this year, Miller had a suggestion: Language saying that children of foreign-born nationals were more likely than non-foreign-born nationals to commit acts of terrorism should be inserted into the report and the accompanying press materials, according to three people with knowledge of his wishes.

But Miller’s move was opposed by Nielsen and her top aides, these people said. They said such language was not substantiated in fact and that a report would not go out from her agency claiming such.

'We're closed!'

Nielsen got a glimpse of Trump’s intense anger over immigration last June when she was present for part of a meeting in which Trump, Kelly, Miller and then-Secretary of State Rex Tillerson began yelling and insulting each other, according to former and current administration officials. Miller was pushing for tighter immigration and refu­gee controls. At one point during the meeting, Miller heavily criticized Tillerson, drawing a rare rebuke from the laconic secretary of state, who said he deserved respect.

Trump sided with Miller and loved his performance, saying Tillerson needed to be tougher, according to these officials.

Nielsen, present for the meeting, was booted by Kelly — who said staff did not need to see such a spectacle.

Kelly grew so angry during the June meeting because he thought the president was uninformed, and he later told associates that it was a staffing problem and a reason he was willing to become the next chief of staff. “The president deserves better,” a White House official said, describing Kelly’s reaction.

As Trump harangued Nielsen for more than 30 minutes in front of the Cabinet this month, other aides grimaced and fidgeted. Nothing she said seemed to calm the president, according to people familiar with the meeting.