DAMASCUS, Syria — In a rare public appearance, President Bashar Assad on Wednesday visited displaced Syrians in a frontline suburb of the country’s capital, where he vowed to keep up the fight against gunmen whom he blamed for driving people from their homes, state TV said.

The visit to a shelter for displaced people in the Damascus suburb of Adra, just northeast of the capital, coincides with advances by his troops battling rebels who captured parts of the suburb in December, displacing thousands from the area.

The visit comes nearly four months before Assad’s seven-year term officially expires. Syrian officials have said the presidential elections would be held on time, according to the constitution.

Assad has suggested he would run again but has not confirmed it. The election must be held between 60 and 90 days before Assad’s term ends on July 17.

The visit to Adra was Assad’s first public appearance outside Damascus since August, when he toured the suburb of Daraya, once a rebel stronghold, and in the same week, took part in a public iftar, the meal that breaks the dawn-to-dusk fast during the Muslim holy month of Ramadan.

“The state will continue to fight terrorism and terrorists who displace people from their homes and commit ugly crimes against them,” Assad said. His government refers to opposition fighters as terrorists.

Photos released by the president’s office showed Assad speaking to women, several of whom were carrying children in their arms. One photo showed Assad putting his hand on the shoulder of a child who was lying on a mattress.

“The government will continue to provide for the main needs of the displaced until they all return to their homes, whether in Adra or other areas,” the TV quoted Assad as saying.

Syria’s civil war, now entering its fourth year, has killed more than 140,000 people. According to UN figures, the conflict has also forced about 2.3 million Syrians to seek shelter in Jordan, Lebanon, Turkey, Egypt and Iraq.

Also, a UN estimate from July said 6.5 million Syrians have been uprooted from their homes and displaced within the country.