If the ancient city of Winchester avoids serious flooding from the coming deluge, it will have to thank a former Pakistan army major and a job lot of gravel from Wickes.

In the early hours of Thursday morning the final 30 tonnes of aggregate were dumped into the swollen river Itchen four miles upstream from the genteel Hampshire city under a plan dreamed up by an engineer with experience handling natural disasters in south Asia and his colleagues at the Environment Agency.

The refreshingly bold scheme to partially dam the river, create new lakes on farmland and hopefully avert an urban inundation is the talk of Winchester's residents who were bracing themselves on Thursday for the downpour that everyone thinks is coming.

The waters are already rising and the 800-year-old cathedral crypt is under a metre of water, which has created a spectacular setting for Antony Gormley's statue of a man, Sound 2. More than 100 sailors from the Royal Navy are shoring up defences and residents are building their own barriers. A council spokesman in the city, ominously the resting place of the bones of King Canute (said to have tried, and failed, to control the tides [see footnote]), warned: "There's nowhere for the rain to go and that could lead to more flooding."

In Water Lane, where sandbag walls defend cottages from the already broken banks of the Itchen, Brenda Hearne, a mother of four, said she was deeply grateful for the upstream dam and reckoned water levels had already dropped.

"It is upsetting that it is farmland, but if it stops us flooding I appreciate it," she said. "If I wore a hat, I would take it off to the farmer."

In fact, two farmers and at least one smallholder have given up land, as Mike O'Neil, operations manager for the Environment Agency in the county, explained.

Standing under a motorway bridge, he detailed how the plan to "save Winchester" came together. One lane of the M3 was closed on Tuesday and Wednesday nights to allow the fire brigade to lower 70 one-tonne bags of gravel ordered from a builders' merchant into the torrent creating a four-metre high wall.

"The levels kept on rising and rising and we thought we had to do something," O'Neil said. "One of our team was a Pakistani army major and he and others came up with the idea. He's worked on earthquakes and all sorts."

The ruse already seemed to be working. Pigs, sheep and horses have all been moved to higher ground, and their fields have started filling with millions of gallons of water. For the embattled Environment Agency, it has been a welcome relief to do something preventative. "It is an innovative solution and at least we are trying something," O'Neil said.

Not everybody has been convinced.

"There has been a mixed reaction," said Amanda Rember, a resident of Easton, the closest village to the dam, who supports the scheme. "There is some concern the valley is being used as a holding tank to save Winchester."

Suzannah Duke, another resident, said: "I think it is probably very sensible. But I do think it is a bit dodgy they are saying it does not increase the risk [of properties flooding] here."

Janet Gray, a smallholder who has evacuated 11 sheep, four pigs and a horse (the pigs went to the abattoir), looked on as some of her 2.5 hectares (six acres) were flooded by the dam. "We live on a floodplain so we don't question it," she said. "Let's save Winchester. It does have to be done."

And so, Winchester braced itself. The military helped erect a metal flood barrier along Park Avenue, where 500 sandbags have been laid and pumps installed. Water Lane resident Brian Cole glued two boards across his gate and backed them up with sandbags.

"The whole street is getting worried about being flooded out," he said.

"Winchester is famously the place where King Canute's bones are buried so trying to hold back the water is something we are used to," said council spokesman Martin O'Neill. "But it didn't work for him and it is a serious issue for us right now [see footnote]."

• This footnote was appended on 14 February 2014:

Reference to Canute's inability to hold back the waves is a popular misconception. According to Henry of Huntingdon's twelfth-century Chronicle of the History of England, it was Christian humility which made him reject his courtiers' flattery by demonstrating that even he could not control the tides.