"These women were spying for the enemy and were arrested by mujahideen [holy warriors]" last week, Sheikh Yusuf Ali Ugas, al-Shabab's regional commander, told the crowd after the execution.
"After a long investigation, they confessed to their crimes," he said, adding that dozens of other people were held at Beledweyne police station on the same charges and faced the same fate.
"Anyone found to be involved in such crimes will meet the same fate and will be executed," the al-Shabab leader said.
'Shocking'
Beledweyne, a town which lies near the Ethiopian border, witnessed heavy fighting between the rebel group and pro-government forces earlier this month.
Ali, aresident of the town, said: "The group informed the population that a punishment was going to be carried out in public on two women they claimed had been found guilty of spying.
"I didn't know they were planning to shoot them. The two girls were sitting on the ground with their hands tied behind their back.
"Then a group of fighters covered their faces and shot them from behind.
"It was shocking, the girls were so young. They looked so desperate but nobody could help them."
Elders and residents gave conflicting information on the girls' ages but both of them were believed to be 17 or 18.
"Everyone was very sorry for the young girls who were killed in front of hundreds," Maryam Ahmed, another witness, said. "I couldn't hold back my tears."
"I'm worried for the dozens of other people who are currently in jail on similar allegations," she said.
Al-Shabab, listed as a terrorist organisation by the US, executed two men on spying charges outside Mogadishu earlier this month.
Condemnation
Abdirahman Omar Osman, the central government's information minister, issued a statement condemning the execution of the girls.
"This execution is yet another human rights abuse committed by the criminals. This act of killing innocent children does not have Islamic and humanitarian justifications," the statement said.
In a case that grabbed the world's attention two years to the day before Wednesday's execution, a group of men stoned a woman to death in the southern al-Shabab bastion of Kismayo after an Islamic court found her guilty of adultery.
Al-Shabab have in recent years repeatedly executed men accused of spying or murder and chopped off the hands of thieves.
Thegroup - formerly the youth wing of the Islamic Courts Union, of which Sharif Sheikh Ahmed, the current Somali president, was a top political leader - controls three-quarters of Somalia.
Ithas beenfighting to toppleSomalia's government and the African Union force that protects the administration.
Somalia has had no effective government for 19 years and Western nations and neighbours say the country is used as a shelter by fighters planning attacks in East Africa and further afield.
Alshabab fighters have publicly executed two Somali teenage girls
Alshabab fighters have publicly executed two teenage girls in the central Somali town of Beledweyne on charges of spying, witnesses have said.