BRUSSELS — One day the war in Ukraine will be over. How and when remain the field of prophecy. But one of the most important questions will be how to ensure the future security of Ukraine — and by whom.

The possible answers are not easy and will depend on the outcome of the war. But what seems clear is that short of a Russian collapse and defeat, with Ukraine winning back all of its territory, any security guarantees are likely to be both partial and fragile.

But without something, officials and analysts suggest, it is hard to imagine investors pouring back into Ukraine to rebuild the country — or that another war would not flare in the future.

Much pivots on the hesitancy of the West itself, which wants to protect Ukraine but has shown that it does not want to fight for it, and that it does not want a direct military confrontation with Russia. Instead it has sought to thread a course between deterring Russia but not provoking it.

There will be “a lot of risks around the corner for European and trans-Atlantic unity,” said Nathalie Tocci, director of the Institute for International Affairs in Rome. If Ukraine manages to regain even the territory lost since Russia’s invasion last year, she said, then there would be mounting voices in Europe and Washington saying, “Look at the ongoing costs, civilian and military — hey, compromise.”

But Ukraine will want solid security commitments in return, she said, and that could divide the West — with Central and Eastern European countries demanding NATO membership for Ukraine, and Western European allies refusing.

While NATO and the European Union have promised Ukraine membership, there is no deadline, and it is not certain those pledges will be fulfilled. The West’s embrace of Ukraine was one reason cited by President Vladimir V. Putin of Russia for his invasion in the first place.

As long as territorial disputes remain, there is little likelihood that even a Ukraine in some sort of cease-fire agreement with Russia would win the unanimous support needed to join either institution.

How the war ends will be crucial, said Thomas Kleine-Brockhoff, who helped write a paper detailing the knotty issues involved in Ukraine’s reconstruction.

Even before last year’s invasion, he noted, Ukraine’s sovereignty was already compromised by Russia’s annexation of Crimea. The neatest outcome now would be if Ukraine won back all of its lost territory, though that is far from certain.

“If it’s a complete Russian defeat, then you solve the Crimea problem and you have a different Russia,” he said. NATO membership would then be easier to envision for Ukraine and it would create a kind of untouchability, even by another revisionist Russian leader, he said. “But the price to get to total victory is very high, and then what?”

The prospect of a complete defeat of Russia, which could undermine Mr. Putin and his circle, embodies risks of Russian escalation that many NATO country leaders, including President Biden, seem unwilling to hazard.

Should Mr. Putin’s leadership collapse, key European states like France and Germany worry about what a chaotic, nuclear-armed Russia could portend, and even about a return to a “time of troubles,” the years of lawlessness, infighting and anarchy that Russia experienced at the start of the 17th century.

But anything short of NATO membership would involve promises that Kyiv already considers hollow. Those were tried before, in 1994, when the United States, Britain and Russia itself promised Ukraine territorial integrity and security “assurances” in return for giving up its Soviet-era nuclear weapons under an agreement called the Budapest Memorandum.

Those assurances came with no commitments — from Russia, of course, but also from Washington and London — and proved worthless.

Anders Fogh Rasmussen, a former NATO secretary-general, has tried to square the circle in “The Kyiv Security Compact,” a proposal he and his colleagues drafted in the autumn with Andriy Yermak, the chief of staff to Ukraine’s president, Volodymyr Zelensky.

It aims to provide something workable between the hollow assurances of 1994 and full NATO and E.U. membership. The core recommendation is for Ukraine’s allies to turn the country into a kind of hedgehog or a porcupine, one so well-armed that Russia would not try to swallow it again.

To get there, it urges a “strategic partnership” between Ukraine and key Western countries, on a bilateral basis, for a “multi-decade effort” to make Ukraine impregnable and capable of its own defense.

Mr. Rasmussen has compared his proposal to the relationship between the United States and Israel, with lots of defense cooperation but no formal defense treaty.

In essence, the proposal is alliance without membership, less a security guarantee to Ukraine than a major disincentive to Moscow.

“The irony is that non-membership in NATO would require more of the West than membership, and for longer,” said Mr. Kleine-Brockhoff.

Others suggest that individual allies, including the United States, Britain, France, Germany and Poland, put their own troops into Ukraine postwar, the way NATO has put forward-based multinational brigades into NATO members states that border Russia.

But significant troop presence in a non-NATO member would be seen in Moscow as a further provocation and more evidence to fit Russia’s narrative that NATO is trying to rip Ukraine away from the Russian sphere.

As Ben Hodges, a retired general who commanded the U.S. Army Europe points out, the United States, Canada and other countries had troops in Ukraine, training the Ukrainian army, right up until Russia’s invasion, when they were withdrawn to avoid a NATO-Russian confrontation. “What would be their mission?” he asked.

Mr. Hodges believes that Ukraine, with the right longer-range weapons from a currently reluctant Washington, can defeat Russia and take back all occupied territory, including Crimea, by the end of August.

“There is no way Ukraine will be safe and secure so long as Russia controls Crimea,” he said. Crimea allows Russia to block the Sea of Azov, isolate Mariupol, hit Odesa and dominate the Black Sea, while claiming an exclusive economic zone around Crimea, limiting fishing and gas exploration, he said.

The only real security guarantee for Ukraine is eventual NATO membership, Mr. Hodges argued. But whatever the outcome, he said, “it must be based on the assumption that Russia won’t respect it unless they’re forced to.”

“Russia cannot be rewarded and think that what they did has paid off with territorial gain or leverage,” he said.

But for many, like Camille Grand, a former NATO assistant secretary-general now with the European Council on Foreign Relations, it remains likely the war will end with Russia having “achieved partial objectives.” A full defeat of Russia and Ukraine joining NATO “is only one scenario, and an optimistic one,” he said.

While anything short of NATO membership “would be difficult to sell to the Ukrainians,” he said, Russia would assume in its war plans that Ukraine would be effectively part of NATO, much as it has always done with Sweden and Finland.

A post-conflict Ukraine “would provide NATO the best-equipped, best-trained and most capable army in Europe — in a way providing NATO security guarantees,” not the other way around, he said.

In a way, the whole idea of security guarantees is outdated, said Stefano Stefanini, a former Italian diplomat in Russia and former ambassador to NATO.

The only real guarantee of Ukrainian security is NATO membership, he said, however complicated. Security guarantees from major countries would be tantamount to NATO membership in any case, he said, and would inevitably carry risks when put to the test.

Even now, individual NATO countries refuse to send troops to aid Ukraine militarily, so why would they do so in the future? he asked.

One could imagine a settlement now where Ukraine loses part of its territory, and a later Kyiv government provokes Russia in order to get it back and then seeks to drag these guarantors into a conflict. What would they do then?

“Even if Ukraine gains NATO membership, it’s a defensive alliance and comes with restraints,” Mr. Stefanini said.

Still, he said, it would be a mistake to underestimate the cynical creativity of diplomats. One could arrive at a point where negotiations produce a commitment for Ukrainian neutrality, but not disarmament, with language about security guarantees, “even if anyone not a politician would call them unrealistic,” he said.

He made the comparison to the Dayton Accords that concluded the Bosnian war, “an awkward acrobatic architecture that only served to end the war.” Even this war will end, he said, and probably in negotiations.

“Total victory for anyone seems unlikely,” he said. So at some point, the diplomats will have to get creative, providing Ukraine some solid prospect of peace and security somehow underwritten by its allies.