TRIPOLI, Libya >> The deserted royal palace here, hidden behind locked gates and an overgrown garden, stands as a monument to Col. Moammar Gadhafi’s virulent rejection of Libya’s monarchy.

Gadhafi overthrew King Idris, the country’s founding leader, in a 1969 coup, but that was not all. He also abolished the monarchy; scrapped the royal flag; banished or jailed the king’s relatives; and turned the gold-domed palace into office space, a library, and after 2009, a lavish private museum for classical antiquities.

Yet the popular memory of King Idris, who died in Cairo in 1983, has quietly endured in Libya. And now, after Gadhafi’s own fall and the years of violent turmoil that have followed, the country’s closet royalists have emerged with a radical suggestion; restore a form of monarchy, at least temporarily, to let Libyans rally behind a respected father figure and begin to rebuild their splintered nation.

The splinters are jagged ones, with rival militias continually scrambling for dominance. In fierce fighting Tuesday in the eastern city of Benghazi, several crucial neighborhoods changed hands. In the west, Islamic State fighters beheaded 12 officials in the town of Sabratha, where U.S. warplanes bombed an extremist camp last week.

“The monarchy offers the most viable way out of the current mess, and it is right for the Libyan people,” said Fathi Abdalla Sikta of the Return to Constitutional Legitimacy Movement. “The king is a symbol of unity for the people.”

Plenty of Libyans deride that idea as a fantasy driven by misplaced nostalgia for Libya’s brief era as an independent kingdom, from 1951 to 1969. The United States and its allies have thrown their weight behind a faltering United Nations-led peace process, based in Tunisia, as the best bet for stabilizing the country.

“We can’t go back 60 years,” said Abdulrahman Swehli, an influential politician from Misrata, referring to the royalist movement. “People who talk about these things are living in cloud cuckoo land.”

The one thing all sides agree on is that Libya’s woes are rapidly getting worse.

Politically, Libya is torn between two rival parliaments — one in Tripoli in the west, the other in Tobruk in the east. Militarily, a kaleidoscopic array of militias that are variously loyal to towns, tribes or religious ideologies vie for control. In Benghazi, where open warfare is raging, the conflict is driven by a bullish militia commander, Gen. Khalifa Hifter; everywhere else, a humanitarian crisis is biting, as oil money, Libya’s traditional source of wealth, is rapidly running out.

Then there is the Islamic State, which in just over a year has captured 150 miles of Libyan coastline where up to 6,500 fighters are based, according to U.S. estimates. That aggressive expansion has attracted fresh recruits from across North Africa. Alarmed Western countries, led by the United States, are mulling a campaign of airstrikes against the Islamic State, also known as Daesh, possibly in the coming months.

Those who say a king can rescue the country point to a little-known crown prince, Mohammed el-Senussi, a grandnephew of King Idris. The prince once worked for the Gadhafi government’s Agriculture Ministry, but then fled into exile in the late 1980s. He was a prominent presence in the news media when the regime tottered in early 2011, offering his services to rebuild the country, but in recent years he has become a more distant figure. He occasionally addresses Libyans through videos posted online, but his website is focused on his hobbies and love of sports and provides little information about his occupation or sources of income.

The prince declined to be interviewed for this article, but an aide in the United States, Alaa el-Senussi, said the prince “was ready to return to Libya if the people demanded it.”

How many Libyans really want that is an open question. But the fact that the idea finds at least nominal support from a broad, and sometimes unlikely, range of Libyans is a sign, many say, of how desperate they are for a leader who can find a way out of the country’s mounting difficulties.

“If this fighting continues, many Libyans will see a return to the monarchy as a viable solution,” said Abdulrauf Kara, an Islamist militia commander who has become a dominant presence in Tripoli. “After five years, people are fed up with the politicians, because they are liars. There’s been so much corruption and waste.”

For the West and for most Libyans, the U.N.-led political process holds the greatest, if most troubled, promise.

Since December, the U.N. envoy, Martin Kobler, has been flying around the region in his small plane in an effort to forge a unity government. But the effort has stalled badly. Heated disputes have erupted over who should be part of the new government’s Cabinet, and Kobler has run into stubborn opposition from the fractious administration in Tripoli, which has lately refused to allow Kobler even to land in the capital.

The biggest point of contention, though, may be Hifter, a onetime CIA asset who returned to Libya in 2011.

In a country full of militia commanders, the general is a uniquely prominent and divisive figure. He paints himself as a fearless warrior against Islamist extremism, and in eastern Libya many people hail him as a hero.

His enemies denounce him as a power-hungry despot in the making. “He is a criminal whose dream is to be a dictator,” said Jamal Naji Zubia, the head of the foreign media office in Tripoli.

Speaking in Cairo last week, Kobler acknowledged that the U.N. peace deal had been cobbled together hastily under Western pressure, and that it suffered from a “legitimacy problem” because it was signed without agreement from all sides.

But, he insisted, Libyans had no choice but to move quickly, particularly given the onward march of the Islamic State.

“We couldn’t afford to negotiate for another six months, particularly with the expansion of Daesh,” Kobler said, pointing to a map showing Islamic State-controlled territory across Libya. “This is a situation where you have to act. There is simply no time.”

Frustration with the U.N. process has helped the royalists. They would be happy with any symbolic figure who could lead the country for a while, said Sikta, the campaigner. But the preferred candidate was Crown Prince Mohammed. “Not forever,” Sikta said. “Just until we hold an election. He can use his influence to bring the militias into line.”

But a king without an army would seem foolhardy for a country awash with weapons and violent grievances. And, in the tradition of Libya’s unruly polity, even the royal family is not immune from factionalism.

In the hotel lobbies of Tunisia and Morocco, where much of the discussion over Libya’s future is taking place, the crown prince faces competition in the form of a cousin, Prince Idris al-Senussi, who is also offering his services as a nation-builder.

“Libyans need someone they can look up to, a father figure,” Prince Idris, a businessman based in Italy, said by telephone. “I don’t say that I should lead. But if people want me to hold a position, then I am willing.”