The gunmen crept into Tolleri village in Ulang county in the early hours of yesterday morning and sprayed it with bullets, killing 23 people instantly, said Dak Tap Chuol, commissioner for the nearby town of Nasir.
The victims of the attack were from the minority Jikany people, the official said, and the attackers were Murle, another minority tribe, who came from neighbouring Jonglei state.
"When people awoke they tried to shoot back but it was too late," Chuol told AFP.
Chuol said that one of a team of village youths that set off hours later to recover the stolen cows was also shot dead, along with three raiders.
More From This Section
Medical charity Doctors Without Borders (MSF), which travelled to the remote area by speedboat on Saturday, took back 16 people with gunshot wounds to its Nasir hospital.
"Two of them have died as the result of their injuries, including one child of eight years old," said Raphael Gorgeu, MSF head of mission in South Sudan.
Fourteen of the patients were women and children.
Chuol said that the only other Murle attack on this area took place on May 19, 2011 and followed a raid by members of rival group the Lou Nuer who retreated north through Nasir County.
"It was assumed that time that they were mistaken. This time round they meant to attack us. This is the first intentional raid on us," he said.
South Sudan, which split from Sudan in July 2011 after Africa's longest civil war, is still torn apart by ethnic rivalry that has become increasingly deadly in a nation awash with guns and deprived of development.