Sydney Water has been fined nearly $270,000 after millions of litres of untreated sewage flowed into a stream in Sydney’s southeast and reached a nearby beach.

The Land and Environment Court heard the first overflow happened between May and June 2017 where up to 334 million litres of wastewater was released into Mill Stream in Botany.

About 173 million litres flowed into the same stream in a second incident in mid-June the same year.

The NSW Environment Protection Authority charged Sydney Water with two water pollution offences and one offence of breaching a condition in its environment protection licence.

Sydney Water pleaded guilty to all charges and was convicted on all three in the Land and Environment Court.

In handing down her decision, Justice Rachel Pepper noted the sewage reached Foreshore Beach in Botany Bay and affected its water quality.

“The amenity of Foreshore Beach was affected by odour, there was an increased risk to the health of anyone who may have had contact with the water at Foreshore Beach until 26 June 2017,” court documents state.

They reveal that the overflows caused “actual harm” by polluting the aquatic environment and degrading the water quality of Mill Stream and Foreshore Beach.

Sydney Water was ordered to pay $150,000 to Bayside Council and $119,500 to the Environmental Trust as well as the EPA’s legal costs.

It will also have to publish details of the convictions in various newspapers, on Facebook, Twitter and Instagram.

Acting EPA chief executive Mark Gifford said the overflows created a potential health risk to anyone exposed to the water at Foreshore Beach.

“These incidents of uncontrolled, raw sewage overflows were significant and could have been harmful to swimmers in Botany Bay,” he said in a statement on Friday.

Sydney Water has apologised and says the wastewater overflow was a result of maintenance work.

“Sydney Water takes its responsibility to protect the environment very seriously and is deeply sorry for this incident,” a spokesman said told AAP.

Sydney Water duly took steps to clean up the area and will conduct an independent review to improve its risk management and governance processes.