* Somalia recovering from more than two decades of civil war
* More security helps hotels and businesses flourish
* Somalis return from abroad with cash and liberal ideas
* Militants still threaten Mogadishu, control other areas
By Abdi Sheikh
MOGADISHU, Oct 17 (Reuters) - Street lamps now light up some of Mogadishu's battle-scarred roads and couples hold hands at the seaside, scenes unthinkable when the Islamist al Shabaab group was in charge of Somalia.
"We feel free," said 18-year-old Samira Aden, emerging from the Indian Ocean with her boyfriend at Lido beach, where women were banned from swimming until just two years ago when African troops drove the militants out of the capital.
Rebuilding a life that many in the world take for granted is a slow and often imperfect process. Islamists still control swathes of countryside and some towns, and have launched several attacks on the city since 2011. Last month they showed their reach by striking a Kenyan shopping mall.
But residents of Mogadishu appear determined to enjoy their new freedoms and not be deterred by the threats.
With al Shabaab no longer in charge, the city's youth flock to the beach or gather at coffee shops to chat, testing the boundaries of a still conservative society.
Residents savour the new routine of shopping at well-stocked stores, filling up cars at gas stations rather than buying jerry cans from roadside vendors, and even enjoying a night out at the clutch of restaurants and hotels rising from the rubble.
"We had none of this freedom during the years of Islamist rule," said Aden, her hair - which would have been covered under al Shabaab's strict version of Islamic sharia law - dripping with salty seawater.
A few main streets are lit by solar-powered lamps. Police are testing traffic lights, but only in their compound for now.
Many overseas Somalis are returning after fleeing during years of fighting, when the country was carved up by clan warlords before Islamists took charge of Mogadishu in 2006. Their money has spawned arts venues and sports clubs.
"Business is booming in Mogadishu," said Abdisalan Nur, manager of the Fathi hotel and restaurant. "We have spaces for men, spaces for women only and spaces for couples."
Near the beach, a new guesthouse has a swimming pool, a tennis court and children's swings. Adults pay $30 a month to join while children can splash in the pool for $3 a day.
That is way out of reach for many Somalis who scrape by sometimes on just a dollar or two a day, however. Prices are being pushed up by the richer returnees.
"It was violent before but life was cheaper then," said Farah Jibril, 36.
The more liberal attitudes of the young and Western-educated people coming from abroad have also become a source of friction.
"I enjoy Mogadishu and the newly born democracy but people from the diaspora have taken it too far," said Sabdow Aden, who is unhappy seeing young people on the beach showing too much affection.
Al Shabaab, which has threatened more attacks, echoes this. "All the evil practices are done by people from the diaspora just to mislead our young generation," an official at the group's media office said by telephone.
Reminders of the fragility of the gains are always present. A suicide bombing closed the National Theatre after it briefly reopened last year. And in June, 22 people were killed when al Shabaab gunmen stormed a U.N. base in the capital.
"The threat coming from Al Shabaab in Somalia is more dangerous and not less," said one Western diplomat, who was also commenting on the attack claimed by al Shabaab on a shopping mall in Nairobi in September in which 67 people were killed.
The government led by President Hassan Sheikh Mohamud, who took over last year, says the Islamist group has been weakened.
"Security is improving by the day and the government is doing everything in its power to contain al Shabaab," presidential adviser Abdirahman Omar Osman told Reuters.
The government still has to rely on an African peacekeeping force whose control in the nation of 10 million barely extends beyond the capital. Many areas in Somalia are still waiting for the peace dividend Mogadishu enjoys.
In the Islamist-controlled town of Barawe, south of the capital, where U.S. special forces launched a failed attempt this month to capture an al Shabaab operative, residents describe a life of constant surveillance and hardship.
"We are not allowed to sit and chat in groups," local elder Farah Siyada said by phone. "You have to answer 100 questions if you are to travel to Mogadishu for medical reasons."
In the capital, residents are keenly aware of the turn in their fortunes.
"I never thought Mogadishu would be as peaceful as it is," said Hamdi Arale, who drives her own car, a practice that al Shabaab banned women doing. "Life has completely changed." (Additional reporting by Feisal Omar in Mogadishu; Writing and additional reporting by Drazen Jorgic in Nairobi; Editing by Edmund Blair and Sonya Hepinstall)