Military personnel escort dairy cows on a barge on the flood-swollen St. John River. ((Andrew Vaughan/Canadian Press))

Some of the cows rescued from a barn amid the flooding that has struck New Brunswick's capital region had a harrowing moment on Friday night while being transported down the St. John River.

The military barge that 57 of the cows were travelling on lost power and began to drift down the flooded, fast-moving current, said Gail Duncan, spokeswoman for the emergency command centre in Burton, N.B., southeast of Fredericton.

"It presented what could have been quite a catastrophe if the barge had hit the pier," Duncan told CBC News.

A military boat travelling along with the barge was able to manoeuvre itself quickly to get between the other vessel and the pier, Duncan said, protecting the animals from the impact.

The 140 cows had become stranded in a barn near Sheffield, southeast of Fredericton.

The owner of the farm had initially thought that his barn would be at a high enough elevation that his animals would be safe from the rising waters.

But the waters rose higher than expected and stranded the animals, said dairy farmer Marco Boonstopple, who helped with the rescue.

The cows were in a desperate situation and stressed, said Robert Speer, a farmer from Hainesville who also volunteered in the operation.

If not milked, cows run the risk of developing an infection, which can block milk production or even kill the animal, Boonstopple said.

The massive rescue operation took all day on Friday as a special barge was assembled to go down the St. John River, which has reached 6.5 metres above sea level in the area. More than 40 army engineers, 21 dairy farmers and two veterinarians participated in the operation.

The operation also had to change its initial plan for saving the animals when the river's strong currents prevented the barge from reaching the barn, Carlin said.

A smaller boat had to be brought in, and the cows were then ferried to the barge about eight at a time, Carlin said.

Once onboard the barge, the animals were moved from the barn to a safe landing point about 20 kilometres away in Oromocto.

The rescue operation was not concluded until about 2 a.m. AT on Saturday after starting in the early hours on Friday.

The animals have now been transported to two farms in Sussex, about 100 kilometres away, to be milked.

There are many farms in the low-lying area on the outskirts of Fredericton where flood waters of the St. John River are continuing to rise.

As they evacuate the area, families are struggling with leaving behind their cattle and horses, Oromocto Mayor Fay Tidd said.

With files from the Canadian Press