The top U.N. envoy in Libya said Thursday there are positive signs that the country is moving toward democracy but longstanding tensions have escalated into armed conflicts, detainees are still being tortured, and there is rising discontent among former revolutionary fighters.

Less than seven months after the end of Moammar Gadhafi's 42-year dictatorship, Libyans are increasingly exercising their freedom of speech and have a strong desire to be consulted on national issues and a determination to hold their leaders accountable, Ian Martin told the U.N. Security Council.

But he said that as the country prepares for the election of a National Congress next month _ the first election in 45 years _ the interim government is still trying to impose rule of law, and there is "a sense of instability in an already fragile system."

Martin reported progress in preparing for the election, noting that since registration began on May 1, over one million people have signed up to vote which "is no small achievement," though only 36 percent are women.

He said another positive sign are local elections starting in Misrata in February, which are being followed by a number of other cities, some in the coming weeks.

"Libyans are increasingly exercising their freedom of speech: free media is developing at a rapid pace and civil society organizations, many of them led by youth and women, are being established across the country," Martin said. "One can clearly sense that for the first time in a generation, people are unafraid to speak out."

With the newfound freedom, however, local conflicts that had been repressed before the revolution are resurfacing, some escalating into armed conflicts, he said.

Martin cited fighting in the southwestern city of Sabha that left 147 people dead in March, fighting between towns in western Libya, and deadly clashes that erupted for this second time this year in the southeastern town of Kufra.

"In each case, the government took swift action in deploying forces and mediation capacities immediately after the conflicts started, and with each case the government's reaction improved and lessons learned were taken into consideration," Martin said.

But he said the government must provide long-term security, deliver services, and pursue reconciliation in those areas and other cities such as Bani Walid and Sirte, Gadhafi's hometown.

Martin said the government faces disturbances from some of the revolutionary brigades over issues including "perceived inequities in the treatment of war wounded" and the suspension of payments to former revolutionary fighters while procedures are put in place to regulate the disbursement of funds.

An attempt by Libyan militias to storm the prime minister's office Tuesday "indicates the seriousness of this discontent," he said. But the failed attack also displayed the government's determination to confront those taking to violence to pursue their demands, he said.

Martin urged stepped-up efforts to demobilize and integrate the revolutionary fighters and control their weapons.

He also urged the executive and legislative branches of the interim government, which have been at odds, to work together to ensure "tangible progress" on security and decentralizing government services before the election.

Martin said he believes the Libyan government is committed to ensuring access to justice for its citizens but "serious obstacles are hampering this process."

The transfer of prisons to the Ministry of Justice is progressing very slowly, with just 31 facilities and 3,000 detainees now under its control, Martin said.

"An additional number of detainees, perhaps around 4,000, are still in the custody of brigades, either at formal or secret detention facilities," he said.

Martin said "cases of mistreatment and torture of detainees continue," citing the deaths of three people at a detention center in Misrata on April 13.

"We have credible information that they were a direct result of torture, as well as information that at least seven other persons were tortured at the same facility," he said

On the economic front, he said there is progress.

Libya is now producing some 1.4 million barrels of oil a day and there are visible signs of new commercial activity but he said reconstruction will not be "fully operational" until security improves and foreign companies and investors return.