The men were whipped in Al-Shihr, a coastal town in Hadramawt province, after being summarily convicted of insulting God and consuming alcohol and drugs, the official said.
Dozens of people attended the flogging, which is said to follow the Islamic sharia law.
Witnesses said each man received between 80 and 100 lashes and that both screamed in pain.
The official said al-Qaida militants have been harassing residents by interfering in all aspects of their daily lives.
Al-Qaida in the Arabian Peninsula controls parts of Hadramawt, including provincial capital Mukalla, which they seized in April.
AQAP has exploited months of fighting in Yemen between Iran-backed rebels and the beleaguered Saudi-backed government to take advantage of the growing chaos.
The United States considers it to be the extremist group's deadliest global franchise and regularly targets its militants with drone strikes on Yemeni territory.
Posted by Women Against Shariah on Monday, August 31, 2015
From the AP via Times of India: