Shashank Joshi is a senior research fellow of the Royal United Services Institute (RUSI) in London. He was previously a research associate at the Changing Character of War Programme at Oxford University, and a Kennedy Scholar at Harvard University. The opinions in this article belong to the author.

(CNN) NATO is the world's largest and most powerful military alliance, having more than doubled in size from its dozen founding members, and has deployed troops all over the world, from the Balkans to Afghanistan.

But its future has been thrown into unprecedented doubt by the election of President Donald Trump. During his campaign, Trump suggested that the willingness of the US to defend its European allies would be conditional on their contributions to the alliance, which he has since called "obsolete."

He also praised Russian President Vladimir Putin while denigrating European leaders, and his officials have welcomed the collapse of the European Union (EU).

This puts European leaders in a difficult position. They currently face the prospect of growing Russian efforts to destabilize their democracies in a year of key elections -- in which populist and far-right movements are gaining popularity across the continent -- and continued turbulence to their east, in Ukraine, and south, in North Africa and the Middle East.

How are they likely to respond?

There are two broad options: work harder to save the alliance, or turn inward and opt for self-reliance. In practice, we are likely to see elements of both, as different countries hedge their bets in different ways.

While France's president said at the EU summit in Malta that "those who want to forge bilateral ties with the US are of course well understood by the public ... they must understand that there is no future with Trump if it is not a common position," and Germany's foreign minister said that "the old world of the 20th century is over," the UK has instead tried to preserve that world by drawing closer to the new American government.

Last month, Prime Minister Theresa May declared that Britain and the US are "united in our recognition of NATO as the bulwark of our collective defense," while the President nodded alongside her in agreement.

On the other hand, the UK believes that to keep Trump on its side, it will also need to persuade other European nations to contribute more to the alliance in the form of higher defense spending.

Today, only four of NATO's 26 European members -- the UK, Greece, Poland, and Estonia -- match the alliance target of spending 2% of GDP on defense. However, 22 of NATO's 28 members increased their defense spending last year, and this trend is likely to continue.

Higher defense spending serves two purposes. For some, like Theresa May, it will help to neutralize Trump's charge that allies are merely free riding on American efforts. After all, even those NATO allies most skeptical of the President are not ready to give up on America.

In January, the President of the EU Council put the "worrying declarations" of the Trump administration in a list of threats that also included Russia, China, and radical Islam . But he also emphasized that "we cannot surrender to those who want to weaken or invalidate the Transatlantic bond, without which global order and peace cannot survive."

If President Trump himself has been amongst those who would weaken NATO, who is left? One answer is Defense Secretary James Mattis, a retired general who served as NATO's Supreme Allied Commander of Transformation between 2007 and 2009. Another is Secretary of State Rex Tillerson, who gave a calm, assured speech on his first day in the office. European states hope that Mattis, Tillerson, and others will prove a moderating influence on President Trump.

However, Europeans also realize that this may not be enough. Mattis and Tillerson can be sacked, and the President has shown a willingness to treat the very closest of allies, like Australia, with open hostility.

Higher defense spending therefore serves a second purpose: it increases Europe's safety net, should the US indeed weaken its commitment to the continent's defense.

That safety net is not very strong. While Europe's collective defense spending is around four times that of Russia, European militaries duplicate a lot of spending, and would be constrained in a crisis by the need for political approval from dozens of different capitals.

One answer to this is more cooperation. But should this cooperation be within NATO, the EU, or something else?

JUST WATCHED Trump and May: The new Thatcher and Reagan? Replay More Videos ... MUST WATCH Trump and May: The new Thatcher and Reagan? 02:24

NATO's Article V -- which says that an attack on one is an attack on all -- does not legally oblige everyone to fight. If Trump decided not to respond, other NATO members could still do so.

But NATO's Supreme Allied Commander is always an American, and the US continues to provide some of the key supporting capabilities, such as refueling aircraft and airborne radar, without which it would be very hard for even Britain, France, and Germany to act on their own.

Some European powers have therefore pushed for the EU to further develop its own defense institutions.

In September, France and Germany -- backed by Italy and Spain -- proposed a permanent military headquarters to plan and run the bloc's military missions, as well as a medical command, a logistics hub, and common officer training. These plans were later diluted, but it is clear that EU defense policy is receiving more attention in Brussels.

Here, the UK is a wildcard. The UK was once a major advocate of European defense cooperation, signing the landmark Saint-Malo declaration with France in 1998. But it has since grown warier of European defense integration, arguing that these efforts distract from NATO and encourage wasteful duplication.

Given Theresa May's eagerness to prove NATO's worth to the new leadership in Washington, she is likely to worry that such steps by the EU will encourage the US to walk away. But Britain is leaving the union and can no longer block what the EU does in the future.

At the same time, the UK is the largest military power in Europe, and far outstrips its allies in some areas, such as signals intelligence.

Any EU military institution that did not include the UK would have a very limited capability. Other European countries, like Poland and Slovakia, also share the UK's view, and would prefer to focus on strengthening NATO.

The first test for Trump's credibility on the issue of European security will come over Ukraine, where fighting between Russia-backed separatists and the Ukrainian government has escalated.

Many feared that Trump might reverse sanctions on Russia, without securing Moscow's compliance with a ceasefire agreement.

However, on Thursday, the US ambassador to the United Nation delivered a stinging, and surprising, rebuke of "Russia's aggressive actions." This will reassure European allies for now, but they will continue to watch how the White House deals with Russia in its first months, and its approach to military allies in Asia.

Speaking in Malta, French President François Hollande echoed Europe's fears. "We must have a European conception of our future. If not, there will be -- in my opinion -- no Europe and not necessarily any way for each of the countries to be able to exert an influence in the world."

Follow CNN Opinion Join us on Twitter and Facebook

Europe cannot be complacent about the Trump administration. But if European leaders push too quickly on defense cooperation outside NATO, they risk widening a rift with the region's largest military power, the UK, and encouraging those who believe that the European security order established after the Second World War is indeed over.

Europe is right to think about greater self-reliance in defense, but it should make every effort to work with those in Washington and in the Trump administration who understand the unique role of NATO.