Pigs can be strong swimmers, as they demonstrate in diving displays that some Chinese pig farms use to improve the animals’ flesh and amuse visitors. But the floods in Anhui appeared likely to overwhelm these factory-farm swine.

“More than 6,000 pigs inside have no hope of survival,” said one of the news reports that ignited national sympathy for Mr. Li and his threatened animals. (A newspaper, The Southern Metropolitan Daily, later said that there were in fact 3,000 pigs stuck in the rising waters.)

Sanitation rules, among other reasons, meant that the pigs could not simply be released to swim for their lives, because that might spread disease or leave animal corpses floating around.

But in a twist worthy of the movie “Babe,” many of the pigs won a reprieve on Tuesday. The government of Lu’an, a city in Anhui, mobilized workers to help relocate the pigs, reported The Paper, a Chinese news website.

“As well, some members of the public came to help of their own accord, and soon, there were 50 or 60 there,” the report said. Another news report showed pictures of rescuers dragging the creatures to safety and herding them on trucks.