* Gaddafi's body on show in Misrata
* Interim premier confirms standing down on Saturday
* Gaddafi family, rights groups want death investigated (Edits)
By Rania El Gamal and Tim Gaynor
MISRATA, Libya, Oct 22 Libya's interim prime minister said he was resigning on Saturday and urged new leaders to seize a "very limited opportunity" and resolve rivalries now surfacing after Muammar Gaddafi's death.
With regional differences emerging about what to do with Gaddafi's still unburied body, the formal end to the war and the carve-up of power, Libya's outgoing premier said the coming days posed a crucial test of resolve for the new men in power.
Mahmoud Jibril said he would step down later on Saturday, after seven months as prime minister of the Western-backed rebel government now that the legal declaration of "liberation" was expected on Sunday following Gaddafi's killing on Thursday.
But in a parting shot at an international business forum in Jordan, he warned Libyans to avoid in-fighting if Libyans were to keep to a plan to hold their first free election next year.
Leaders required "resolve", he said, "in the next few days".
In Misrata, the curious and the relieved filed for a second day through a market cold store to view the body of Gaddafi, whose surprise capture and killing in his hometown of Sirte sparked joy - and renewed jockeying for postwar influence.
Visitors wore surgical masks against the stench, an image that may trouble some Muslims, for whom swift burial is a holy duty - even if few Libyans share the unease among their Western allies over what some believe was a summary execution.
Jibril said progress for Libya would need great resolution, both by interim leaders on the National Transitional Council and by six million war-weary people: "First," he said, "What kind of resolve the NTC will show in the next few days?
"And the other thing depends mainly on the Libyan people - whether they differentiate between the past and the future."
He added: "I am counting on them to look ahead and remember the kind of agony they went through in the last 42 years.
"We need to seize this very limited opportunity."
The formal declaration of an end to war and of "liberation" from Gaddafi's rule was expected to be made by NTC chairman Mustafa Abdel Jalil on Sunday in the eastern city of Benghazi, the seat of the revolt inspired by the fall of autocrats in neighbouring Tunisia and Egypt.
There have been several delays to the announcement. It will set a clock ticking on a plan for a new government and constitutional assembly leading to full democracy in 2013.
Jibril reaffirmed the plan was for elections to the body that will draft a constitution to be held in eight months.
Gaddafi's body remained in Misrata, bearing wounds assumed to have been inflicted by fighters from the city who hauled him from a drain in his hometown Sirte. A field commander in Misrata worried that trouble was brewing:
"The fear now is what is going to happen next," he said, speaking to Reuters privately, as ordinary Libyans, some taking pictures for family albums, filed in under armed guard to see for themselves that the man they feared was truly dead.
"There is going to be regional in-fighting. You have Zintan and Misrata on one side and then Benghazi and the east," the guerrilla said. "There is in-fighting even inside the army."
Comparisons with Iraq after Saddam Hussein are tempered by the absence of the Sunni-Shi'ite divide which ravaged that country. However, as in Iraq, there are vast energy resources at stake and international powers keen to exploit them.
Regional enmities thrive, as well as differences between Islamists and secularists and among those who once served Gaddafi - like NTC head Abdel Jalil - and others. There is also ethnic tension between Arabs and Berbers.
Gaddafi's surviving family, in exile, have asked that his body and that of his son Mo'tassim be handed over to tribal kinsmen from Sirte. NTC officials said they were trying to arrange a secret resting place to avoid loyalist supporters making it a shrine.
Unlike on Friday, Gaddafi's body was covered by a blanket that left only his head exposed, hiding bruises on his torso and scratch marks on his chest that had earlier been visible.
A Reuters reporter who viewed the body said Gaddafi's head had been turned to the left. That hid a bullethole that earlier could be seen on the left side of his face.
Gaddafi's family and international human rights groups have urged an inquiry into how Gaddafi, 69, was killed, since gory cellphone video footage showed him alive but being beaten and taunted by his captors. Jibril said on the day that Gaddafi was killed in "crossfire" in an ambulance taking him to hospital.
But an ambulance driver in Sirte told Reuters Gaddafi was already dead by the time he picked him up, and a local military commander in Misrata said "over-enthusiastic" fighters had taken matters into their own hands:
"We wanted to keep him alive. But the young guys...," he told Reuters. "Things went out of control."
The International Criminal Court at The Hague had wanted to try Gaddafi for war crimes and may yet be able to try his son Saif al-Islam if he is found. NTC officials believe he escaped from the last redoubt in Sirte, after French jets had scattered a convoy of dozens of vehicles trying to flee with his father.
Intelligence chief Abdullah al-Senussi, the third man wanted by the ICC, managed to reach Niger, officials have said.
Libyans also want to try some of the old guard at home.
Despite the qualms of some abroad, few compatriots are troubled by Gaddafi's bloody end, captured in clips of cellphone video broadcast around the world.
"People in the West don't understand the agony and pain that the people went through during the past 42 years," said Jibril, who added he felt "reborn" when he heard the news.
Abdulatif, a pilot, who came to see the body in Misrata, asked: "What would he tell the mother whose children were killed or the girls who were raped? If he lived and was killed a thousand times that would still only be a trifle."
Nonetheless, some Libyans have expressed unease at the way Gaddafi's body has been treated - Muslim custom dictates it should have been buried by sundown on Thursday - and at other matters of religion and respect for the dead.
Gaddafi's daughter Aisha, her mother and two of her brothers fled to Algeria after the fall of Tripoli. Aisha gave birth on the day she arrived.
The government in Algiers has angered the NTC by refusing to send them back. But an Algerian newspaper on Saturday quoted official sources saying that, following the death of the head of the family, they might now reconsider. (Additional reporting by Taha Zargoun in Sirte, Barry Malone, Yasmine Saleh and Jessica Donati in Tripoli, Brian Rohan in Benghazi, Christian Lowe, Jon Hemming and Andrew Hammond in Tunis, Samia Nakhoul in Amman, Tom Pfeiffer at Dead Sea, Jordan, David Brunnstrom in Brussels and Lamine Chikhi in Algiers; Writing by Alastair Macdonald; Editing by Andrew Roche)