Somali Islamist fighters
According to reports from a small village near the town of Wajid, 250 miles (400km) north-west of the capital, Mogadishu, the woman was taken to the public grounds where she was buried up to her waist.
Somali Islamist fighters
The Islamists want to impose a strict version of Sharia on Somalia
She was then stoned to death in front of the crowds on Tuesday afternoon.
The judge, Sheikh Ibrahim Abdirahman, said her unmarried boyfriend was given 100 lashes at the same venue.
Under al-Shabab's interpretation of Sharia law, anyone who has ever been married - even a divorcee - who has an affair is liable to be found guilty of adultery, punishable by stoning to death.
An unmarried person who has sex before marriage is liable to be given 100 lashes.
BBC East Africa correspondent Will Ross says the stoning is at least the fourth for adultery in Somalia over the last year.
Earlier this month, a man was stoned to death for adultery in the port town of Merka, south of Mogadishu.
His pregnant girlfriend was spared, until she gives birth.
A girl was stoned to death for adultery in the southern town of Kismayo last year. Human rights groups said she was 13 years old and had been raped, but the Islamists said she was older and had been married.
Last month, two men were stoned to death in Merka after being accused of spying.
President Sheikh Sharif Sheikh Ahmed, a moderate Islamist, was sworn in as president after UN-brokered peace talks in January.
Although he says he also wants to implement Sharia, al-Shabab says his version of Islamic law would be too lenient.
The country has not had a functioning national government for 18 years.