A toddler has died after being pulled unconscious from a backyard pool in Sydney's west, while a young boy is in hospital after nearly drowning in a lagoon.

The two-year-old girl was pulled from the water just before 8pm on Wednesday at Werrington Downs and treated by paramedics but later died in hospital.

Police are investigating the circumstances around the incident.

A few hours earlier, two children were pulled from the water at Avoca Beach, on the NSW Central Coast.

A four-year-old boy and three-year-old girl were rescued by bystanders, who treated the pair until paramedics arrived.

The boy was airlifted to The Children’s Hospital at Westmead in a serious condition, while the girl was taken to Gosford Hospital for observation.