For the Muslims of Trappes, decades of praying in basements and cramped rooms in decrepit buildings will soon be over, once the finishing touches are applied to their new, hard-won mosque — a shiny domed structure with a minaret and wooden Moroccan doors.

It took sit-in protests in front of City Hall in Trappes, some 45 miles southwest of Paris, to get approval for the mosque in 2000.

With different customs, beliefs and often skin color, parts of France's large immigrant population have been shunted to the margins of French life and left to struggle with dual identities.

Those tensions partly explain the eruption of rioting that has engulfed low-income suburbs and towns — including Trappes — for nearly two weeks.

Trappes' new mosque, now open for Friday prayers and soon to be open full-time, offers hope for many here that, with a proper venue allowing Muslims to worship in the open, youths may be less tempted to turn to religious radicalism.

"We wanted a respectable place of worship," city councilwoman Khadija Aram said of the new $2.7 million mosque. Aram, a secular Muslim of Algerian origin, has lived in Trappes for 30 years.

"Christians have their church, Jews have their synagogue and Muslims pray in the basement," she said. "French Muslims are not yet at home in France."

But across the nation, many Muslims say they are still humiliated by the need to pray in cramped quarters in the basements of housing projects because of a lack of mosques.

Even in Paris, Muslims are forced to spill out onto the street, worshipping on trash-strewn pavements, at Friday prayers because some mosques are so small. France has some 5 million Muslims, the largest such community in western Europe.

The social unrest has forced the nation to confront immigrants' feelings of discrimination and France's shortcomings in integrating them.

Since colonial times, France's emphasis on integration has translated into a strong drive to assimilate cultures into a single French mold according to the nation's strong secular traditions.

In 2004, a law banning "ostentatious" religious symbols, and aimed at Islamic head scarves, went into effect — angering many Muslims.

Immigrants and French of immigrant origin — often Muslims from former colonies in North Africa — largely populate the low-income quarters ringing big cities.

In such conditions, Muslims "have no means to weigh in on decisions that could change their own situation," said Angelina Peralva, a sociologist who specializes in urban violence. "They are so consigned to their world that, collectively, they can't get out."

In Trappes — where about 70 percent of the 29,000 residents are Muslims — the National 10 highway cuts through the city like a demarcation line, the French downtown area on one side and the vast expanse of housing projects on the other.

"Religion offers a reference point," said Bechier Lassoued, a board member of the Union of Muslims of Trappes, which built the mosque and led the protests to get it. "Someone who follows religion normally doesn't get lost."

"For Muslims, religion is fundamental. Religion is life," he said.

Trappes has had its share of terrorism fears — linked to the practice of worshipping underground.

In September, police arrested four terror suspects in Trappes and are investigating evidence suggesting a plan to attack targets in France.

The alleged ringleader, Safe Bourada, served eight years in prison for helping Algerian Islamic extremists and was being lodged here by friends. The men had frequented a prayer room in the projects, Lassoued said.

Since the Sept. 11 attacks in the United States, French authorities have taken steps aimed at pulling Muslims from the shadows if only to watch them more carefully.

Interior Minister Nicolas Sarkozy has condemned the plight of Muslims forced to pray in cellars because of a lack of mosques.

In March 2005, a foundation, to be privately funded, was set up to help finance mosque renovation and construction. A council that acts as an umbrella group for squabbling Muslim factions, and a link to the government, also was created.

The Muslims of Trappes have been saying prayers in a small room on the ground floor of an aging building for years. The overflow crowd prays in the basement.

On feast days, the huge crowds of faithful pour into the adjoining lot — or climb a ladder to the roof of a one-story building nearby.

"Fundamentalists and terrorists take in those who have been marginalized by the politicians," said city councilwoman Aram said. "To have a mosque open to all avoids anything deviant. It's in daylight. There is no secret."