Central Otago District Council water services manager Russell Bond said contractors were on site to install a centrifuge as part of an upgrade project when the incident happened early on Tuesday.
The 37cm-diameter pipeline, which carries sewage from the Alexandra township including Bridge Hill, was punctured by a digger, leaving a hole about the size of a kitchen sink.
As gravity carried the raw sewage towards the Manuherikia River - only a couple of hundred metres away - Mr Bond said the quick-thinking contractors dragged some dirt from the hillside with a digger to create a dam.
The result was a pool, which Mr Bond estimated to be the size of a backyard swimming pool, in which the sewage was able to be contained while temporary repairs were made to allow the sewage to bypass the hole.
Mr Bond said he was "very pleased" with how they managed to contain what was potentially quite a large environmental disaster.
He said the sewage was scraped up and stored on site, with Otago Regional Council consent, until it could be taken to the landfill at Victoria Flats.
The contaminated area was then sprayed with chlorine to disinfect it before lime was applied to control the odour.
River water sampling took place yesterday and the river will continue to be monitored, as will the site.
Mr Bond said they would not get the results for a few days but the regional council was fully aware of the situation.
The hole in the pipeline was fixed by 11pm on Tuesday night and signs have been erected to warn people.
Mr Bond said the warning signs would remain until both the district and regional councils were comfortable there were no risks.
He said the incident was still being investigated, and it was not known how much it had cost or whether it would be covered by insurance.
The results of the investigation would also determine whether any preventive measures were needed to avoid another such incident.