SOUTH PORTLAND — Somalia was on the verge of civil war when Deqa Dhalac fled the capital city of Mogadishu 31 years ago and began her journey to become the first Somali-American mayor in the United States.

On Monday afternoon she was formally seated as the top elected leader of Maine’s fourth largest city. Her latest accomplishment was the subject of a joyous phone conversation on Sunday with her mother, who still lives in Mogadishu.

Her mom recalled the prayer she recited to Dhalac when her daughter began high school. From now through eternity, her mother said at the time, be a leader in a community of people from all backgrounds, and may the light of your father guide you to a better future.

Dhalac had forgotten her mother’s prescriptive words. She was happy to be reminded.

“It was so beautiful,” Dhalac said before Monday’s ceremony. “It brought tears to my eyes.”

After serving three years as District 5 city councilor, Dhalac was formally elected Monday afternoon by her six fellow councilors to lead them and the city in 2022.

Abdullahi Ahmed, principal of Deering High School in Portland and a leader of Maine’s Somali community, delivered the opening prayer at the council’s inauguration ceremony. He congratulated Dhalac for demonstrating, despite setbacks that come with prejudice, what the human spirit can accomplish with support from a welcoming city.

“You are here to build on the work that was ongoing,” Ahmed said. “We are so proud of you, Deqa.”

Reza Jalali, executive director of the Greater Portland Immigrant Welcome Center, was among many leaders of Maine’s immigrant community who attended the ceremony at South Portland High School.

He is a Kurd who was born in Iran. “All of us new Mainers take personal pride in this,” Jalali said as he arrived.

The Council on American-Islamic Relations, the nation’s largest Muslim civil rights and advocacy organization, praised Dhalac’s election “as a sign of the increasing civic involvement of the American Muslim community,” spokesperson Ibrahim Hooper said. “We hope Mayor Dhalac will help inspire a new generation of American Muslims as they take an increasing role in building a better society.”

In becoming mayor, Dhalac takes on the additional duties of running council meetings and spearheading citywide initiatives for the same $3,000 annual stipend that each councilor receives. A longtime social justice and human rights advocate, she works for the Maine Department of Education as its family engagement and cultural responsiveness specialist.