The decision released by the court said the issues around the applications were complex.
The total wastewater nitrogen and phosphorus loads, including from intensive farming activities which would continue on the land after the facility is built, were not included in the primary resource consent application, and by the time the hearing was completed, data on the environmental impacts of the scheme was out of date.
The Environment Court also acknowledged it was difficult to reliably predict how much nitrogen would reach the places surface-water run off could reach, both now and in the future, and that by the beginning of the hearing, modelled predictions showed nitrogen discharge losses below the "root zone" looked to have increased by more than 20 per cent.
The court said the combination of factors made it difficult to determine if they had enough information to make an informed decision on the applications by HDC, but they determined that there were "methods available to address and provide for the technical uncertainties" and that they were not prevented from granting consents.
The decision said disposal to land was, to all intents and purposes, the only option available to HDC in meeting provisions of the human sewage discharge policy of the One Plan, and that there was limited, if any, land near Foxton that was suitable.
The discharge-to-land consents were subsequently granted after a lengthy hearing process.
The Matakarapa site will continue to be used for the farming of bull beef in conjunction with the treated wastewater discharge process under an arrangement with the owner.
Andrew Grant, group manager infrastructure services for Horowhenua District Council, said it had been a long process.
"We are delighted to move forward, and I thank my predecessor, Gallo Saidy. His leadership got us to this point."
Grant said there would be a limit of 2000 cubic metres discharged on average per day.
"Council will give high priority to inflow and infiltration projects in Shannon and Foxton," he said.
Foxton Community Board chairperson David Roache said the issue was historical and they were pleased to see it resolved. The board, which was listed as a party to the proceedings, hoped the scheme would set a good example for its neighbours, Roache said.
"We're over the moon. It's a great day for Foxton, for the Manawatū River Loop, the estuary and the Manawatū River."
Council chief executive David Clapperton said Horowhenua will be one of the only councils in the country, if not the only one, to have all its treated wastewater discharged to land, and not into waterways.
"Gaining the consent for 31 years is a significant achievement that everyone in our district should be proud of," he said.
"Council has been on this journey for over a decade – now our focus is on gaining consent for land discharge for treated wastewater from Tokomaru treatment plant."
The council said the court had complimented it on its "open, comprehensive and well-documented process" for investigating possible sites and said it had gone to "considerable efforts to consult in a genuine, open way".
Some aspects of the process had been kept under wraps though.
Matakarapa Island contains sites of cultural significance to Māori, and a draft copy of a confidential agreement between the council and "the affected hapu of Matakarapa" Te Runanga O Raukawa Incorporated, was leaked on social media during the hearing process.
The leaked document, dated September 2017, outlined financial assistance to be provided by the council to Te Runanga O Raukawa in return for the withdrawal of submissions to the Environment Court opposing the scheme.
The Court decision documents show withdrawals by Te Taiao O Ngati Raukawa Environmental Unit and Te Roopu Taiao o Ngati Whakatere on September 28 2017.
Clapperton said the leaked copy of the document was "nowhere near" the actual agreement, but that he was unable to comment on the contents of it as negotiators were still going through the process of communicating it, he said.