BEIRUT, Lebanon — The diplomatic situation had been looking bright for President Bashar al-Assad of Syria. With the help of Russia, he had consolidated his power, the rebels were on their heels and the United States had just declared that ousting him was not a priority.

So why would Mr. Assad risk it all, outraging the world by attacking civilians with what Turkey now says was the nerve agent sarin, killing scores of people, many of them children? Why would he inflict the deadliest chemical strike since the 2013 attacks outside Damascus? Those attacks came close to bringing American military retaliation then. And in a stunningly swift reversal, Tuesday’s attack drew a response from President Trump: dozens of cruise missiles launched at a Syrian air base.

One of the main defenses offered by Mr. Assad’s allies and supporters, in disputing that his forces carried out the strike on Tuesday, is that such an attack would be “a crazy move,” as one Iranian analyst, Mosib Na’imi, told the Russian state-run news site Sputnik. Yet, rather than an inexplicable act, analysts say, it is part of a carefully calculated strategy of escalating attacks against civilians.

For years, at least since it began shelling neighborhoods with artillery in 2012, then bombing them from helicopters and later from jets, the Syrian government has adopted a policy of seeking total victory by making life as miserable as possible for anyone living in areas outside its control.