SANAA, Yemen — Airstrikes killed 18 al-Qaida-linked militants in central Yemen on Saturday while separate strikes targeted militants in the south, officials said, as the military struck back at the group after it killed nearly 200 of its soldiers.

The military offensive comes in response to an attack last week in which al-Qaida’s militants sneaked across the desert at dawn to the back lines of Yemeni forces. Many of the troops were asleep in their tents when militants sprayed them with bullets. Their bodies, many of which were missing heads or mutilated, were later dumped in the desert.

The bloody assault on the military in Abyan province revealed the magnitude of the Yemeni army’s defeat after nearly a year of political turmoil across the country that has left an emboldened al-Qaida in its wake.

Yemen’s new president, Abed Rabbo Mansour Hadi, faces the heavy burden of trying to dislodge the militants. He was sworn in as president Feb. 25 after taking over from Ali Abdullah Saleh, who ruled the country for more than three decades.

Al-Qaida has long had a presence in Yemen, the poorest country in the Arab world. But in the chaos of last spring they established a much stronger foothold in southern Yemen and since then have tried to push north into the central province of Bayda. From there, the group could extend its reach into the capital. In January, al-Qaida militants stormed a local prison and freed at least 150 inmates in the town of Radda.