The officials say militants first attacked a security checkpoint early today in the town of Wassab in Damar province, killing one soldier, then fled to the nearby Hudayda province.
Security forces pursued the militants into Hudayda, where clashes lasted for nearly two hours.
The officials say two militants died and four were arrested. They spoke on condition of anonymity in line with regulations.
Yemen's al-Qaida branch, also known as Al-Qaida in the Arabian Peninsula, is considered by the US to be the terror group's most dangerous offshoot.