No other nation means more for what Nato is than the United States. It holds a unique position among member states due to its political, economic and military weight. Which is why the forces that dominate American politics – and who is in the White House – are such decisive factors. The presidential election in November 2016 was therefore not only important to the US, but also to all of Nato.

For the first six months of 2016, Hillary Clinton was ahead in every poll. By autumn, election experts were predicting her victory. I, too, had a gut feeling this would be the outcome. On election night, my wife Ingrid and I arranged a party with friends and colleagues at the residence in Brussels. We rigged up a large television in the living room, and hamburgers were served. A long day lay ahead, so I turned in before midnight.

I woke at five and checked my phone. Donald Trump had taken Pennsylvania and Ohio. It still wasn’t 100% certain, but CNN had reported he was going to win. When I came down to our election breakfast at six o’clock, the others were clearly just as surprised as me.

I was anxious about what would happen next, because I had noticed how critical of Nato Trump had been during his election campaign. In a television interview towards the end of March, he had said “Nato is obsolete” – a view that undermined American foreign policy of the past 70 years. Trump received pushback from a number of Republican heavyweights, but it seemed to glance off him. At around the same time, he was asked who he would consult when he needed foreign policy advice. “I’m speaking with myself, number one, because I have a very good brain,” he replied.

The American people had elected Trump, and we had to respect that. I wanted Nato to establish a good working relationship with him as quickly as possible, in order to get him and his administration to take a more positive view of the alliance. Within Nato, self-discipline would be necessary. I made it clear exasperated groaning at internal meetings was unacceptable. There would be no eye-rolling at Trump’s tweets or public appearances; no mocking laughter over videos; no jokes about golfing or his mannerisms. Zero tolerance was crucial. Just a small group of individuals poking fun can spread through an organisation and trickle out. And should it reach Washington that Nato staff were sitting around laughing at Donald Trump, it would be ruinous.

On Friday 18 November, I got Trump on the line for the first time. “I’m a big, big, big fan of Nato! Great to speak with you, looking forward to working with you,” he said. During our conversation, I was a little shocked that we mostly seemed to agree on the crucial matters. Trump believed the European member states needed to spend more on defence. “On that I completely agree with you,” I said. Fairer burden sharing and increasing defence spending were what I had spent most of my time working on since taking office. Nato needed to be better prepared in the fight against terror, Trump said. “On that I completely agree with you,” I replied again.

He also wanted to hear my thoughts on the individuals he was considering for key positions. I was surprised, but I didn’t contradict him. Rex Tillerson for secretary of state? I knew him a little from the oil industry and from energy conferences in the 90s. “A good choice,” I said.

Jim Mattis for secretary of defense? The truth was, the little I knew about him came from the HBO series Generation Kill about the Iraq war, which I had watched with my son: Mattis is portrayed as a mythic figure, a general both feared and admired, who goes by the call sign Chaos. There was a slightly embarrassing pause before Torgeir Larsen, who, as director of my private office, was listening in on the conversation, handed me a note. It said: Jim Mattis is great. He knows Nato.

“Jim Mattis is great. He knows Nato ,” I told Trump.

After that first conversation, I felt things looked brighter. Like many others, I disagreed with Trump’s views on climate change, abortion rights and trade policy, but the substance of what he had said about Nato in our conversation was something I could work with.

Shortly after the election, Barack Obama invited the incoming president to the White House. It was a conciliatory affair. Trump thanked him for his efforts; Obama said everything an outgoing president should.

This, too, I found encouraging. Things are going to calm down, I thought: now the election was over, Trump would be shaped by his new role and its responsibilities. With competent people around him, Trump would become more like his predecessors in the White House.

That was the second incorrect assessment I made of Donald Trump.

In mid-April 2017, I was at the White House, ready to meet Donald Trump for the first time. I had prepared a few pleasantries about the election victory and Melania, the first lady. The door opened to his office, but no president stood there waiting. Trump lounged casually in a chair.

“Come on in, guys,” he said, smiling.

When Trump had greeted Japanese prime minister Shinzo Abe a few weeks earlier, the handshake lasted 15 seconds, and was so hard Abe winced. Canadian prime minister Justin Trudeau was subjected to similar treatment. A little later, French president Emmanuel Macron chose to grip so hard, his knuckles turned white. All this had been much reported on, with some commentators believing Trump was trying to assert his superiority through his handshake and others pointing out he was concerned with his masculine image. Not long before my visit, he had met German chancellor Angela Merkel, and refused to shake her hand in front of the photographers. Much was written about that, too.

When Trump got up, hand outstretched, I was a little apprehensive. But his grip turned out to be almost disappointingly normal, neither hard nor loose.

That handshake: Donald Trump and French president Emmanuel Macron get to grips at a Nato meeting in 2017 … … and again, watched by German chancellor Angela Merkel, at a G20 meeting. Photographs: AFP/Getty Images

When the conversation began, however, it quickly became apparent this was going to be extremely loose. We jumped from one topic to the next. Talking about Russia, Trump suddenly exclaimed, “But why can’t you guys in Nato join us in Korea? They’re developing nuclear weapons, and that’s something we can’t accept.”

A couple of months earlier, North Korea’s leader, Kim Jong-un, had declared that preparations for the testing of an intercontinental nuclear missile were now in their final stage; this announcement was followed by the firing of medium-range missiles, which landed in the Sea of Japan. So Trump bringing up North Korea wasn’t completely out of the blue. But I was unsure as to what he meant. Did he want Nato to intervene in North Korea?

“Mr President, all the allies are concerned about the nuclear weapons, but I don’t think there will be any support for bombing North Korea,” I said.

“But you’re in Afghanistan. Why can’t you be in North Korea?” he replied, before the conversation swiftly moved on. We touched on terrorism and Islamic State, of course, with Trump declaring, “We have to kill them, we have to bomb them, they’re really evil people.”

Soon our conversation returned to Russia, and I repeated the points I had been keen to make since taking office in Nato . “We must be strong and predictable, but be open to maintaining a dialogue with Russia. Russia is here to stay. It’s a neighbouring country, not a terrorist organisation that needs to be eradicated, like IS,” I said.

Then, as I had done in many other conversations, I referenced Norway’s experiences. “You know, Mr President, as former prime minister of Norway, I know that it’s possible to speak with the Russians.”

Trump cast a questioning look. “Are you Norwegian?”

I understood why he was asking – over the years I’ve received many heads of organisations myself, and it isn’t always easy to remember where each comes from. I smiled. “Yes, I’m Norwegian.”

“Do you know Celina Midelfart?”

“Yes, I’ve met her several times. She’s a well-known person in Norway,” I replied.

“Nice girl. What they wrote about us in the Norwegian papers – was it good or bad?”

I remembered seeing newspaper images of Trump and the Norwegian cosmetics heiress and investor at some sporting event or other, but more than that I couldn’t recall. I had no idea what the papers had said.

“Oh yes, the reporting was positive. She’s married to a rich Norwegian now,” I said.

“He’s not rich.”

So the president of the United States clearly knew who investor Tor Olav Trøim was. But were you rich if you had a few billion kroner to your name? Possibly not, in Donald Trump’s eyes.

To the script from which Trump was reading, a few words had been added in thick black marker: ‘MUST PAY’ and ‘NOT FAIR’

After about 20 minutes, our private conversation was over. Trump’s advisers and several members of my delegation joined us. I noticed my colleagues looking on anxiously as Trump and I shook hands once more for the photographers. But everyone was cheated out of a potentially amusing anecdote.

For Trump, the most important issue was Nato members’ defence spending. I wanted him to take a more positive view of the alliance and had brought along a graph that illustrated spending was increasing. Trump was most concerned with the fact that only five member states had achieved the goal of spending 2% of GDP on defence. I pointed out that several countries were close, and six or seven set to reach the target in the near future. Then there was Iceland: it has no armed forces, so would never spend 2% of its GDP on defence. It was therefore actually five out of 27 countries who had achieved the goal, rather than five out of 28, I said, thinking I may be coming across as rather nerdy with all these figures.

But this caught Trump’s interest, if not in the way I had intended. “Then what do we want with Iceland?”

Before I could say anything further, Jim Mattis came to my aid, explaining how important Nato’s bases there were for the alliance’s submarines, ships and planes: “Mr President, they’re good to have if you want to track down Russian subs.” Trump thought for a moment. “Well, then we’ll let Iceland stay a member,” he said.

In Nato, we never roll out the red carpet – we roll out a blue one. On Thursday 25 May 2017, we rolled out an extra-long, extra-wide bright blue carpet, all the way from the main entrance to the road leading to Nato HQ. The blue was reflected in the colour of our flag, which symbolises the Atlantic Ocean, around which the alliance is gathered. Everything was ready for a grand ceremony with Nato heads of state and government in attendance.

On this day, President Trump would make his first appearance at a Nato summit, and we would also be inaugurating the alliance’s new headquarters. While I was looking forward to leading the proceedings, I also felt somewhat apprehensive. Following our meeting in the White House some weeks earlier, uncertainty as to how Trump really viewed Nato had arisen again.

Article 5 of the North Atlantic Treaty is Nato’s collective defence clause and represents the very core of the alliance: one for all and all for one. Trump had refused to offer a clear “yes” to the question of whether the US continued to stand behind this assurance, despite persistent questioning by the press. “Why should we protect countries that aren’t willing to pay for their own security?” Trump had said. This made many of the allies uneasy. The way they saw it, Trump was reducing Nato to little more than a protection racket.

After exchanging a few pleasantries, the plan was to take Trump to a place where the text of Article 5 is carved into the wall, so photographs of the two of us could be taken in front of it. I had intended to offer Trump a few facts about the new building and Nato, but his constant questions kept cutting me off. “Do you really need such a big headquarters?” he asked. “What do you need all these people for?”

I replied that while the organisation itself isn’t that large, member states’ delegations also use the building – it makes it easy to meet with security measures in place, and everyone uses the same cafeteria. I told Trump who had designed the headquarters: architects Skidmore, Owings & Merrill, who also designed the Trump International Hotel & Tower in Chicago.

“I know those people. They’re extremely expensive,” Trump exclaimed. “I don’t understand why you chose those expensive architects. Extremely expensive!”

In front of the main entrance, a small avenue of newly planted trees had been constructed, with lawns on either side. On one of these stood a twisted steel girder from the Twin Towers in New York; on the other, a couple of segments of the Berlin Wall. Two testaments to some of the most momentous events in Nato’s history. I introduced Angela Merkel as a speaker by reminding everyone that she had been living in Berlin not only when the wall was erected in 1961 but also when it was torn down in 1989 and Europe changed for ever.

“Each day, all those who enter this building will pass this memorial. They will understand that freedom will never be defeated. And Nato will always defend the values on which our alliance is founded,” I said. Merkel expressed her gratitude for Nato’s presence during the cold war and said the fall of the wall symbolised that democracy wins out, even after many years of struggle.

‘All the leaders wore grave expressions. Everyone understood things were on the brink of collapse’: the 2018 Nato summit. Photograph: Sean Gallup/Getty Images

Then it was Trump’s turn, standing before a piece of the mangled remains of the Twin Towers. The memorial’s full name is the 9/11 and Article 5 Memorial, to emphasise how it symbolises the solidarity within Nato. I introduced Trump by stressing this unity. “Nato’s greatest strength is the enduring bond between North America and Europe. We saw the strength of that bond after the 9/11 attacks against the United States,” I said.

“And President Trump,” I continued, “those attacks struck at the heart of your own home town, New York. And for the first time, Nato invoked our collective defence clause, Article 5. One for all, and all for one.”

I had teed up the shot for him. All Trump needed to do was highlight Nato ’s efforts when the United States was attacked, and reassure everyone present that the same would apply to them should they ever need help.

Trump began by speaking at length about the threat of terrorism. This wasn’t so strange – just three days earlier, on 22 May, a suicide bomber had attacked the city of Manchester in the United Kingdom. Trump condemned the attack, which had killed 22 people and injured hundreds. After this, he touched on the threat represented by Russia.

But then came the accounting accusations. “Twenty-three of the 28 Nato nations are still not paying what they should for their defence,” Trump said. “This is not fair to the people and taxpayers of the United States.”

On the previous day, we had privately been handed a copy of the speech the president would give. It was excellent, with all the important points covered, including the Article 5 obligations. But somewhere along the way, Trump must have chosen to give a different speech than the one that had been prepared.

As I stood beside him, I was able to glance down at the script from which he was reading. A few words had been added in thick black marker: “MUST PAY”, “NOT FAIR” and “2% is the absolute minimum!” He had clearly crossed out certain things and added others, to amplify the message. Here he was, dedicating the 9/11 and Article 5 Memorial, yet he hadn’t said a word about Article 5.

One Friday in the summer of 2018, a couple of weeks before the Nato summit in Brussels, I was due to speak with Trump by telephone. It was a call he had requested, and as we had recently met in Washington, it wasn’t clear why he had asked to speak to me again.

skip past newsletter promotion

Sign up to Inside Saturday

The only way to get a look behind the scenes of the Saturday magazine. Sign up to get the inside story from our top writers as well as all the must-read articles and columns, delivered to your inbox every weekend.

Privacy Notice: Newsletters may contain information about charities, online ads, and content funded by outside parties. If you do not have an account, we will create a guest account for you on theguardian.com to send you this newsletter. You can complete full registration at any time. For more information about how we use your data see our Privacy Policy. We use Google reCaptcha to protect our website and the Google Privacy Policy and Terms of Service apply.

Trump launched into telling me how great things were going in the United States. The economy was running in high gear, despite the fact that he’d been handed a country in ruins. But he hadn’t called me to brag. Defence spending, and the sharing of the financial burden between Nato ’s member states, was what he really wanted to talk about.

“Germany is paying 1%! It’s shocking.” According to him, Merkel was in trouble.

I told Trump she was working to increase Germany’s defence budget, but as leader of a coalition government, it wasn’t always easy to reach a consensus. Trump cut me off. “Migration is the big problem. It was a terrible decision.” He was referring to all the refugees that had fled to Germany during Europe’s refugee crisis.

Then he returned to the defence budgets. Spain was spending less than 1% of GDP on defence. King of Spain Felipe VI had just made a state visit to Washington, and been received at the White House.

“They were here and they said, ‘Thank you for the military protection.’ But Spain’s economy is good. This is very unfair.”

Trump had recently met with Merkel, too, and told her things simply couldn’t carry on the way they were. “I said, ‘Angela, you have to cough up. You need to spend 2%.’ She said, ‘Maybe in 2030’ – and she laughed as she said it … She laughed!”

He said the United States was spending 4% of GDP on defence, and covered 80-90% of Nato’s expenses. “And we’re not doing it any more. We’re gonna pay what Germany pays.”

By the end of the call there was no mistaking Trump’s warning: “Look, if we leave, we leave. You need Nato, desperately. We don’t need Nato.”

If the United States withdrew, the alliance would be dead. Trump had made me responsible for its possible dissolution. He wanted me to set things straight before the summit. And the summit was 12 days away.

“Nato is important, but it’s way more important for Europe than the United States,” Trump said when the summit convened in Brussels on 12 July 2018. “American presidents have come here and said this for years. Then they’ve gone home and nothing has happened. It’s only gotten worse. I have great respect for Angela. My father was born in Germany. My mother was born in Scotland. So in a way I’m part of the EU. But this has to stop.”

Some of the things he said were clear warnings. “The US doesn’t need Nato. Why should I continue to pay for this organisation when I don’t need it?”

There was silence around the table. Trump continued to talk at length about the trade imbalance with the EU, another hobby-horse. “The EU sends its BMWs and Mercedes into the United States, almost tariff-free. It can’t go on like this. It won’t go on like this.”

Then came more criticism of Europe. “The borders you have are terrible. Angela has said many of the people streaming in are young men. That doesn’t sound good. They might be enemies,” Trump said. “I have great respect for Europe. I have great respect for the secretary general, who has managed to bring in more money. But it’s very little compared to what we need … You have to pay your share. Angela could pay 2% today, if she wanted to! Instead she says 1.5% by 2025!”

‘We have to talk about this now,’ Trump reiterated. ‘Otherwise – you know, otherwise, we’re not going to be friends’

Trump then moved on to the other allies. “I don’t want people leaving this meeting saying everyone was happy. I am not happy. You could have made me happy. When a rich country doesn’t pay, it’s because they’re trying to trick us, the way they tricked every single president since Reagan. You have to pay. Two per cent is so little. It’s a joke! You need to aim for 4% if you want proper protection. Either you pay 2% immediately, or by January 1st. Otherwise, we’re going to … do our own thing. We have no choice. And as you already know, I really disagree with this building. Three billion dollars for a building like this! It’s ridiculous! The United States is paying! It’s a beautiful building, but a single shot from a tank and this building will collapse.”

When Trump finished speaking, Angela Merkel stood up, came around the large meeting table and leaned over me. “We have to respond to this,” she whispered. “We can’t just let it pass.” It was clear she feared the meeting might end up spiralling out of control. I nodded.

We took a break of a few minutes. I conferred with Angela Merkel, Emmanuel Macron and Dutch prime minister Mark Rutte in a corner, while Trump sat close by, his arms crossed, speaking with his security adviser John Bolton and secretary of state Mike Pompeo. We agreed it was out of the question to change the 2% goal, but discussed how we could best handle the situation and pacify the president. My staff were also in contact with colleagues, trying to establish a way forward.

When the meeting resumed, Trump reiterated his demand for immediate promises of increased spending. “We have to talk about this now. Otherwise – you know, otherwise, we’re not going to be friends,” he said.

Then, finally, it came, the moment I had feared since our conversation 12 days earlier, when Trump had said the United States would only continue to be a member of Nato if Germany and the United States paid the same.

“I’m leaving this meeting. There’s no reason for me to be here any more,” Trump said.

Now everything’s going to fall apart, I thought. I looked around the room. All the leaders wore grave expressions. Everyone understood things were on the brink of collapse – the entire summit, all the declarations of agreement. If an American president says he no longer wishes to defend the other allies and leaves a Nato summit in protest, then the Nato treaty and its security guarantee aren’t worth very much.

This might be the meeting at which Nato is ruined, I thought. And it’s happening on my watch. The alliance had managed to operate successfully for 70 years – but not after 12 July 2018.

Angela Merkel expressed what many were thinking. “We have to take this back to our parliaments and national assemblies,” she said. “We aren’t able to make the decisions here. I will fight hard to meet the 2% target in 2024. But I simply don’t have the majority for anything more than that right now.”

Trump and Stoltenberg at a Nato working dinner in 2017. Photograph: Matt Dunham/AFP/Getty Images

Then Trump did something that rarely happened at such meetings. He interrupted another head of government. “That’s too long,” he said. “Way too long.”

But Merkel kept speaking, using an expression we often heard from Trump. “I have to say that I don’t feel I’m being treated fairly here. You speak frankly, Donald, so I will do the same. Germany is the second largest contributor of forces to Nato. 9/11 and Afghanistan are the only time Article 5 has ever been invoked. This has contributed to protecting the United States, despite intense opposition in my country, where many asked what Afghanistan has to do with us. Germany can do more, and we can probably do things better. But now we must stick to the commitments we have made.”

Everyone agreed the member states would increase their defence budgets to 2% of gross domestic product. But the problem was that Trump insisted on it happening this year. The other nations set the goal of achieving the target in 2024, something that had also been adopted in the summit declaration the previous day.

Trump took the floor again, rattling off how much each member state spent on defence as a percentage of GDP as if he were announcing the Eurovision song contest results. “Belgium: 0.9. That’s less than 1%. Croatia – oh, I’m so disappointed in you, I can’t believe it: 1.26%. You must feel rotten,” he said, searching for the relevant leader with his eyes. “Estonia: 2%. Thank you! France: 1.79. Not bad, Emmanuel. Not bad for you. You haven’t been president long enough, it’ll probably go down. Germany: 1.2. Come on, Angela! Come on!”

He went on. Until finally: “United Kingdom: 2.1. Thank you. That’s very good. United States: 4.2% of the biggest gross domestic product of all. So you may as well call us idiots. But I haven’t been at this party very long. How stupid is this? That’s all.”

He leaned over towards British prime minister Theresa May and said something. Then he turned to Recep Tayyip Erdoğan, the president of Turkey, who was sitting on his other side, and high-fived him.

Several other leaders spoke. Some sympathised with Trump’s demand for immediate increases in spending, while others were as reserved as Merkel and Macron.

Then I gave the floor to Mark Rutte. This was no accident. He and I had met for lunch in The Hague a week before the summit, where we had discussed how we could get Trump to support Nato, including by pointing to the fact that defence spending had increased by $33bn.

“Mr President, you have urged us to spend more, and I agree with you,” Rutte said. “And that is exactly what we are doing. Last year, we spent $33bn more on defence because of your leadership. So this is good news for you.”

Trump liked this. Thirty-three billion. He nodded.

After a while, he took out the thick black marker he always used, jotted something on a sheet of paper, then handed it to me. His handwriting was neat and rather attractive. The note said: “Secretary general, if you can say the Nato allies have significantly increased their defence spending thanks to me, I think we can agree.”

I finally glimpsed an opportunity to bring the meeting home. I took the floor myself.

“At the press conference after the meeting, I will state that the Nato allies have significantly increased their defence spending thanks to President Trump’s leadership and clear messaging,” I said, practically reading straight from his note. Then I added, “And at the same time, that all member nations remain committed to Nato and to Article 5 of the treaty.”

I hoped against hope this would be enough to bring the meeting to a close in a way that was acceptable to everyone. The problem was there were still 12 leaders remaining on the list of speakers. If I allowed the debate to start up again, it seemed extremely likely that at least one of them would say something that irritated Trump, causing the fragile consensus to be broken. I therefore looked pleadingly around the table, at Merkel, Macron, May, Trudeau, Erdoğan and all the others, and suggested something highly unusual – that we move to stop the discussion now, with everyone in support of my proposed conclusion. “Can we agree?” I asked.

There were nods around the table, and for a moment I thought both the day and Nato were saved. But no. Lars Løkke Rasmussen, prime minister of Denmark, raised his hand and made it known that he was not going to withdraw his name from the list of speakers.

Løkke Rasmussen, a cheerful and down-to-earth Dane whom I liked very much, began cautiously, saying something about the importance of us standing united in difficult times, and agreeing it was important to share the financial burden fairly. Then he fixed his gaze on Trump and paused. “But sharing the burden isn’t just about money, Mr President. It’s about blood and sacrifice. Denmark is a country of only five million people, and we have lost 45 soldiers in Afghanistan, in a response to an attack on the United States.”

He had clearly had enough. His voice shook as he said, “By population, Denmark has lost more soldiers in Afghanistan than the United States.” He refused to look their families in the eye and say their loved ones’ lives mattered less because Denmark hadn’t met the 2% target.

The episode reminded me of a scene in Love Actually, where Hugh Grant, playing the British prime minister, stands up to the American president. But this was no movie – it was reality. I realised it was right that Løkke Rasmussen had been permitted to speak. Still, I held my breath when he was done.

Trump stayed quiet. Everyone understood they were at a historic meeting, and several leaders now wished to become part of the story by taking the floor, but I wasn’t going to allow them to speak. The meeting was over.

Trump held his press conference immediately after. “The United States’ commitment to Nato is very strong, remains very strong, but primarily because everyone – the spirit they have, the amount of money they’re willing to spend, the additional money they will be putting up has been really, really amazing to see it. To see the level of spirit in that room is incredible,” he said.

He also brought up the $33bn. “The allies will spend at least $33bn more, in addition to what we previously agreed. We are more united than ever. No problem.”

To this day, I remain surprised at how Trump accepted the summit’s conclusion. Had he made good on his threat to leave in protest, we would have been left to pick up the pieces of a shattered Nato. I think he realised he was banging his head against a wall with his demands of immediate budget increases, but at the same time, he departed Brussels convinced he would have more money by the new year.

When I met him at the UN headquarters in New York a few weeks later, he smiled, satisfied. “Is the money still coming in, secretary general?” he asked.

“Mr President, the money is flowing in,” I replied.

This is an edited extract from On My Watch: Leading Nato in a Time of War by Jens Stoltenberg, published by William Collins on 23 October at £25. To support the Guardian, order your copy at guardianbookshop.com