The victim is believed to be a nine-year-old girl who went missing last week from a property in the Blue Mountains near Sydney, police said.
Her disappearance sparked a massive search that ended on Tuesday when officers discovered the child’s body near a river in a neighbouring area.
Police said a 31-year-old man had been arrested in a flat in inner Sydney.
He faced a court on Wednesday but did not enter a plea on a murder charge or apply for bail. His next hearing will be in March.
The girl – who cannot be identified for legal reasons – was on holiday with her mother when she disappeared last Thursday. She was reported missing the next morning.
Over the next five days, police officers, firefighters and State Emergency Service volunteers scoured dense terrain in the area for clues.
Meanwhile more than 200 officers conducted an investigation that identified the suspect and “anomalies” in his movements, according to New South Wales Police.
“That has been quite a laborious task in analysing GPS data, analysing CCTV footage and leading us to search the location we searched last night,” Deputy Commissioner David Hudson said on Wednesday.
He said it showed the suspect had purchased a “number of sandbags” from a hardware store, as well as fuel to “try and float” a boat at a dock in inner Sydney.
“That was unsuccessful because the boat was inoperable,” Deputy Commissioner Hudson said.
The suspect allegedly later travelled to the Colo River area – where the barrel was later found. It is not far from where the girl originally went missing.
“Until the post-mortem is conducted, we are still uncertain of what exactly happened to her,” Deputy Commissioner Hudson added.
“What we are sure of is that the accused that we charged with murder was responsible for, firstly, placing her in the barrel, and then disposing of that barrel in the bushland where she was located.”
During Wednesday’s court hearing, the suspect’s lawyer said his client had long-term mental health problems. Prosecutors said there were “complexities” in the case, without elaborating.
Police said investigations would continue.
Identifying child victims of alleged crimes is prohibited under state law without permission from their next of kin, the Sydney Morning Herald reported.