The unidentified man was in hospital in critical condition after sustaining a single bullet wound to the head, said Jalaluddin Abdul Rahman, deputy police chief in southern Johor state.

"All the 30 children, aged between three and five years, and their four teachers are safe," he was quoted as saying by national Bernama news agency. A Johor police officer confirmed Jalaluddin's comments.

The officer, who declined to be named, said the man was wielding a machete and a hammer when he barged into the nursery in a residential area in Johor, sparking a stand-off with police.

The man, believed to have mental problems, forced the hostages to go upstairs in the two-storey building. During negotiations with police, the man threatened to kill the children unless he was given a gun, the officer said.

Police special forces later managed to enter the ground floor and were heading up the stairs when the man attacked them with his weapons and a fire extinguisher, the officer said.

Police had no choice but to shoot the man, he said, adding that they were investigating his identity.

Bernama reported that the children were heard singing in what was believed to be an attempt to calm the man.