‘I alone can fix it.” On 21 July 2016, as he accepted the Republican presidential nomination in Cleveland, Ohio, Donald John Trump spoke more than 4,000 words, but these five would soon become the tenet by which he would lead the nation.

That night, Trump stood by himself at the centre of Quicken Loans Arena on an elevated stage, which he had helped to design. A massive screen framed in gold soared behind him, projecting a magnified picture of himself along with 36 American flags. This was a masculine, LED manifestation of his own self-image. His speech was dark and dystopian. He offered himself to the American people as their sole hope for renewal and redemption. Past presidential nominees had expressed humility, extolled shared values and summoned their countrymen to unite to accomplish what they could only achieve together. But Trump spoke, instead, of “I”.

“I am your voice.”

“I will be a champion – your champion.”

“Nobody knows the system better than me, which is why I alone can fix it.”

It would be all too easy to mistake Trump’s first term for pure, uninhibited chaos. His presidency would be powered by solipsism. From the moment Trump swore an oath to defend the constitution and commit to serve the nation, he governed largely to protect and promote himself. Yet, while he lived day to day, struggling to survive, surfing news cycles to stay afloat, there was a pattern and meaning to the disorder. Trump’s north star was the perpetuation of his own power, even when it meant imperiling the US’s shaky democracy. Public trust in American government, already weakened through years of polarising political dysfunction, took a body blow.

Yet Trump’s own recklessness hampered his ability to accomplish the very pledges on which he campaigned. From the start, government novices and yes men made up much of his inner circle, a collective inexperience that exacerbated the troubles, wasted political capital, and demoralised committed public servants. The universal value of the Trump administration was loyalty – loyalty not to the country, but to the president himself. Some of his aides believed his demand for blind fealty – and his retaliation against those who denied it – was slowly corrupting public service and testing democracy itself.

Two kinds of people went to work for the administration: those who thought Trump was saving the world and those who thought the world needed to be saved from Trump. The latter, who at times were drawn in by his charm, were seasoned and capable professionals who felt a duty to lend him their erudition and expertise. Yet as the months clicked by, the president wore down these “adults in the room” with what they considered the inanity, impropriety and illegality of his ideas and directives. One by one, these men and women either resigned in frustration or were summarily dismissed by Trump. He engaged in a constant cycle of betrayal, rupturing and repairing relationships anew to keep his government aides off balance to ensure the continuity of his supremacy. Some of them now sigh from a distance at a president they hoped to guide and the realisation that fewer voices of wisdom remain to temper his impulses. They lament a president who nursed petty grievances, was addicted to watching cable television news coverage of himself, elevated sycophants and lied with abandon.

Trump stepped into the presidency so certain that his knowledge was the most complete and his facts supreme that he turned away the expertise of career professionals upon whom previous presidents had relied. This amounted to a wholesale rejection of the US’s model of governing, which some of his advisers concluded was born of a deep insecurity. “Instead of his pride being built on making a good decision, it’s built on knowing the right answer from the onset,” a senior administration official said.

In the weeks before the 6 November 2018 midterm elections, Trump barnstormed the nation, singularly focused on illegal immigration. He fixated on a slow-moving migrant caravan consisting mostly of families fleeing violence travelling on foot from Central America, through Mexico, and towards the US to seek asylum. Trump warned voters that the caravans were in fact a dangerous “invasion” of migrants threatening the safety and prosperity of US citizens. Privately, Trump demanded that his aides take “tough action” at the border to demonstrate strength. No one came under more pressure from the unrelenting president than Kirstjen Nielsen, the secretary of homeland security and a close ally of the White House chief of staff, John Kelly.

Trump’s relationship with Nielsen had been tempestuous from the start, as he made her a battering ram for his stance on illegal immigration. He routinely complained to other advisers that Nielsen was not doing enough to secure the border; her defenders said she was doing all she could within the confines of the law. In some instances, the volatile president was verbally and emotionally abusive toward Nielsen. “Kirstjen, you’re just not tough enough,” Trump would tell her.

Trump complained that Nielsen did not “look the part” of homeland security secretary. He made fun of her stature and believed that at about 5ft 4in, she was not physically intimidating. “She’s so short,” Trump would tell others about her. She and Kelly would try to make light of it. Kelly would rib her and say: “But you’ve got those little fists of fury!”

Facebook Twitter Pinterest Former homeland security secretary Kirstjen Nielsen at the White House with Donald Trump in January 2019. Photograph: Carlos Barría/Reuters

A number of federal agencies bore responsibility for managing the influx of migrants. The justice department housed asylum judges and administered the legal process. The State Department negotiated with Latin American countries and issued visas. The Department of Health and Human Services oversaw the care of migrant children. The army corps of engineers managed construction of the border wall. But in Trump’s mind, everything related to immigration and the border fell under the Department of Homeland Security, and he held Nielsen accountable for it all.

At a cabinet meeting on 9 May 2018, Trump berated Nielsen in front of roughly two dozen administration colleagues over the rising number of illegal border crossings. In an explosive, extended tirade, a red-faced Trump excoriated Nielsen for not bringing him enough “solutions”. Then Trump instructed Nielsen to “shut down” the southern border. Attorney general Jeff Sessions, whose relationship with the president was the most strained of all the cabinet members, seized an opportunity to get on the boss’s good side for once. Seated across the table from the president, Sessions interjected: “I just think we’re not being tough enough. I think we need to shut down the border.” Trump concurred and, turning to Nielsen at the far end of the table, asked: “Why haven’t you shut down the border?” It was more of an admonition than a question. Nielsen knew this would be illegal, not to mention economically disastrous because it could choke off trade routes.

“I’m not sure what we are saying here,” Nielsen said. “As the attorney general knows, people have a legal right to cross the border and try to claim asylum. That’s just the law.”

Trump looked back at Sessions.

“No,” Sessions said. “We should just shut the border down.”

Trump then lit into Nielsen. Why couldn’t she use the power of her department to keep immigrants from flooding into the US? What was so hard about this? Trump was so worked up that some attendees thought he looked manic. Kelly silently shook his head at Nielsen to signal to her to stop engaging with the president. Jared Kushner, Trump’s son-in-law and senior adviser, made eye contact with Nielsen and moved his finger across his neck to signal to her to cut it off. It was clear to others in the meeting that Nielsen hadn’t properly read the room or the president. By the time Trump eventually tired of yelling at Nielsen, nobody had stuck up for her – not even Kelly. He had decided that speaking up would only further provoke the president. After the cabinet meeting had concluded, Mick Mulvaney, the director of the Office of Management and Budget, said to Trump: “You know, the attorney general was wrong about the law. The attorney general is saying this, but that is not the case.” But it was too little too late.

Trump’s abuse continued episodically through the summer and autumn. He harassed Nielsen with angry phone calls, waking her as early as 5am and routinely calling her at 6.30am and 7am as she was heading to work. He also pestered her late at night. Once, after the president had heard a rumour from a Republican lawmaker that a mid-level homeland security official had been disloyal to the president during a classified briefing, Trump became obsessed with getting the man fired.

He called Nielsen late at night demanding she remove the official from his job. “That doesn’t sound like something he would do, but I’ll look into it, sir,” she had told him. He had called Nielsen back early the next morning. “Is it done?” the president had asked. Nielsen explained that she couldn’t check as her employees had been asleep overnight.

Trump regularly called Nielsen after watching Lou Dobbs’s nightly show on Fox Business. Dobbs delivered regular diatribes about illegal immigration, proposing unrealistic solutions and castigating Nielsen as a squish. To Trump, the Dobbs monologues were gospel and created in the White House a near-daily drumbeat. The president would routinely call Nielsen to say a version of “Did you see Lou Dobbs? You’re totally fucking embarrassing me. This is my issue!” One of his go-to complaints was: “They’re killing me,” a reference to Fox’s coverage of immigration policy. “You’ve got to fix it,” he would demand of Nielsen. Sometimes, Trump would refer to one of Dobbs’s proposals and say: “Kirstjen, just do it. Just do it.”

“But we can’t do it,” Nielsen would explain, usually because whatever Dobbs had uttered on TV was against the law. Other times, when Trump would call Nielsen and demand she execute one of Dobbs’s ideas, she would interrupt the president’s yelling to inform him: “Sir, we’re already doing that. I briefed you on that the other day.”

Nielsen recognised the power Dobbs had over Trump, and saw that his commentary was infecting her relationship with the president. The White House communications shop had tried to book Nielsen on Dobbs’s show, but he had declined, saying Nielsen wasn’t “my cup of tea”. As the volume of border crossings spiked, Dobbs had a show focusing on the administration’s failure to enact three ideas to secure the border. Nielsen shook her head as she watched. One proposal was legally shaky, the second had already been discarded by the administration because it was impossible to implement and the third was something the administration was already doing.

Nielsen called Dobbs from her car to correct him. Her aides listened fearfully, sure she would start yelling at the TV host, but she was gracious. “Lou, we’d be happy to help you with your reporting,” Nielsen said. “If you ever need any facts or statistics or one of our experts, we’d really be glad to provide it.” She then went over why the three ideas he had outlined on air were not workable. Within hours, Trump called Nielsen. He was excited. “Did you call Lou Dobbs?” he asked. She said she had. “That’s great,” Trump told her. “Lou says you’re very smart!”

Get the Guardian’s award-winning long reads sent direct to you every Saturday morning

One of Nielsen’s tactics for when Trump asked her to do something illegal – or something that violated a regulation or a treaty – was to ask him: “OK, sir, what are you trying to accomplish here?” She would then try to figure out a legally permissible way to achieve the same result and often arranged briefings to try to inform the president what he could and could not do. “Let me bring people in,” Nielsen would tell Trump. “You don’t have to trust me.” But the briefings rarely made an impression on Trump. Just when Nielsen thought an illegal or unfeasible idea had been put to bed, the president would awaken it. Trump did not see the law as an impediment – a mindset forged as a real estate developer. A developer could always just sue, battle it out in court and negotiate some middle ground.

“Look, we’ll get sued and then we’ll work it out,” Trump told Nielsen during one such discussion. “Just block people from coming in.” Stopping people from seeking asylum was a favourite solution of the president’s. But he had many ideas, and they would sometimes feel like a sandblast of suggestions, any one of them violating the international conventions on torture or US rules requiring the study of environmental harm, or regulations governing competitive contracts. Lawyers from the Department of Homeland Security and the White House rarely pointed this out to Trump. Nobody wanted to get him even angrier. Just as he used to recoil from former White House counsel Don McGahn’s repeatedly telling him he couldn’t do some of the things he wanted to do, Trump got frustrated with Nielsen.

“Federal law enforcement doesn’t work like that,” Nielsen told Trump in one such meeting. “People could get in trouble. These people have taken an oath to uphold the law. Do you really want to tell them to do the opposite?”

“Then we’ll pardon them,” Trump said.

“The White House was so broken,” one administration official later remarked, looking back on this tense period on immigration policy. “There was no process. Ideas would come to the president in a no-process method. Half-baked ideas come in to him. God knows how. It was totally disorganised. To this day, no one is in charge at the White House. No one.”

In late October 2018, with the caravan on the move, Trump badgered Nielsen almost endlessly. He suggested lining up border agents and other officers to form a sort of human wall along the portion of the southern border that lacked fencing, roughly 1,200 miles (1,931km) of the 1,933-mile border. A statistician at Homeland Security figured out it would take hundreds of thousands of people standing arm to arm to create a line that long. The number, a conservative estimate, was immediately discarded because it was so staggering. “We were like, this is absurd,” one aide remembered.

Nielsen and her team, including the leaders of Customs and Border Protection and US Citizenship and Immigration Services, met for a brainstorming session in downtown Washington’s Ronald Reagan building. Sitting around a conference room, they discussed how to satisfy Trump’s increasingly difficult demands to deny entry to illegal immigrants. The officials felt as if they had already scraped the bottom of the barrel for new options. They contemplated a number of ideas, including sending US marshals to the border, borrowing personnel from another department or creating a volunteer army. They figured they had to throw some bodies at it, if only to sate Trump. National Guard units had deployed 2,100 troops to the border since the spring, and some homeland security officials suggested ramping up the presence dramatically to create, as one aide put it, “a huge show of force”.

At this moment, the border situation was relatively calm. There was no crush of migrants – the caravan was still a few weeks away from reaching the border – and the humanitarian crisis in overcrowded border stations would not unfold until several months later. One senior agency official interjected to point out that additional personnel at the border was not necessary, at least not yet. “This is ridiculous,” the official said.

It was not, however, ridiculous to Trump. He was adamant about sending troops to the border, telling aides that the military had tens of thousands of men and women in uniform and he should be able to use them, as commander-in-chief, to protect the sovereignty of the US. Advisers explained to Trump that if he sent troops to the border, they would not be allowed to function as if they were law enforcement officers. They could erect temporary fencing or fix vehicles or conduct surveillance, advisers said, but they could not use deadly force. Firing a single shot into Mexico would be considered an act of war. (Nielsen resigned in April 2019 after repeatedly failing to get Trump’s office to listen to her proposals for resolving the border crisis – including her efforts to work with northern triangle countries to manage the exodus of migrants.)

In late October 2018, Trump decided to use his authority as commander-in-chief to deploy military troops to the border to guard against migrants. On 29 October, the Pentagon announced that it was sending 5,200 troops, as well as Black Hawk helicopters and giant spools of razor wire. This was the largest mobilisation of active-duty troops along the US-Mexico border in decades. The next day, Trump floated the idea of sending 15,000 troops to the border, an extraordinarily large number that was roughly the size of the US military presence in Afghanistan. The move immediately inspired howls that Trump was playing politics, militarising the border to scare voters and turn out his base in the midterm elections, which were now just a week away. But the secretary of defense Jim Mattis vouched for the mission and said the military was providing “practical support” to homeland security operations. “We don’t do stunts in this department,” he said.

Nevertheless, Trump made clear that his rush to put troops at the border was about taking strong action to galvanise his supporters to vote Republican. “If you don’t want America to be overrun by masses of illegal aliens and giant caravans, you better vote Republican,” Trump said in November at a rally in Columbia, Missouri.

Facebook Twitter Pinterest US troops install razorwire fences along the US-Mexico border in El Paso, Texas state. Photograph: Hérika Martínez/AFP/Getty

For Trump, deploying the troops wasn’t enough. He wanted images – propaganda – distributed through the media showing the military presence. Trump sent word to the Pentagon that he wanted pictures of troops at the border. The presidential demand landed on the desk of Dana White, Mattis’s press secretary. Kevin Sweeney, a retired navy rear admiral who was serving as Mattis’s chief of staff, told White that the White House needed to see pictures of troops – and fast. White tried to explain this would be unrealistic. This was the Department of Defense, not Coca-Cola. Troops would not be moving to the border instantaneously, even after they received orders. “I can’t give people pictures of something that’s not happening,” White told Sweeney.

“That’s your problem, Dana,” Sweeney said. “Just get the damn pictures.”

The pressure wasn’t coming from Sweeney, of course. It was coming from the top. Trump had pushed the entire military apparatus to help him illustrate the show of might that he had ordered, which could convince voters that he was protecting the nation from the dangerous “invasion” of migrants that was getting closer each day to a showdown at the border. Sweeney and every senior agency official knew the fastest way to please the president was to get the message on the station he and his fans power-watched. “Get something on Fox immediately,” Sweeney told White. Trump just didn’t understand that US armed forces don’t simply hop on a C-17 one night and start patrolling the banks of the Rio Grande the next afternoon. “No one would push you to show that, except the one person who doesn’t know,” a defense department official said of the president.

‘This guy doesn’t know anything’: the inside story of Trump’s shambolic transition team Read more

Mattis’s aides agreed that to satisfy Trump’s wishes they would have to get pictures of National Guard troops and asked state National Guard officials who hadn’t yet shipped out if they could snap photographs or shoot video of their reserve troops training at home. The first images they got – after more than 24 hours of hustling – were of the Texas National Guard, the first to have images of troops in drills. “People were more focused on the pictures rather than what we are allegedly doing,” the defense department official said of the White House. “The urgency wasn’t on the mission. It was on getting the pictures.” Trump also wanted to see military generals being interviewed on TV news, preferably at the border and in a commanding role. Word came down from the White House that images of National Guard officials were not good enough.

By 3 November, the first wave of military troops had arrived at the border and photos emerged of uniformed service members installing razor-wire fencing along the Texas side of the Rio Grande. Trump remarked at a campaign rally in Montana that evening: “We have our military on the border. And I noticed all that beautiful barbed wire going up today. Barbed wire, used properly, can be a beautiful sight.”

• This is an edited extract of A Very Stable Genius: Donald J Trump’s Testing of America, published by Bloomsbury. To order a copy for £16, go to the Guardian Bookshop.

• Follow the Long Read on Twitter at @gdnlongread, and sign up to the long read weekly email here.