Authorities in Kwadwesi, South Africa, have charged a father with attempted murder after he threw his baby from the roof of a shack in protest of the demolition of illegal homes in his village.

The unidentified 38-year-old man had climbed to the top of his house with his six-month-old child looking to stop dozens of homes, some of which were built illegally, from being torn down.

The incident happened Thursday morning in the Joe Slovo township in Kwadwesi near Port Elizabeth on South Africa's eastern cape, Daily Mail reported.

Half-a-dozen police officers had gathered on the ground below the home in an attempt to talk the man down. Once police saw that he could not be calmed, an officer climbed up to the roof. The man was seen dangling his baby off the structure by her ankle, before swinging her over the edge. 

"At about 10.40am a 38-year-old man climbed onto the roof of one of the structures and held a one-year-old girl in his hands," police spokesman Captain Andre Beetge told local media. "This was done to force the team not to demolish the structure."

The girl was unharmed and fell into the arms of a nearby policeman. An officer then rushed to the roof and apprehended the father, placing him in handcuffs. 

"Due to the dangerous threat to the safety of the child police set out a plan to rescue the little girl and arrest the male and one of our officers successfully caught the girl as she was flung," he added.

Captain Beetge said the baby was given back to her mother and that authorities were working to ensure the child's safety. 

"The 38-year-old father has been charged with the attempted murder of his daughter and the case is being handled by the Family Violence, Child Protection and Sexual Offences unit."

After the incident, the demolition team moved in and deconstructed about 90 homes that had been built illegally on the unowned land. 

Over 150 protesters began rioting, throwing bricks and closing off roads in protest of the destruction of their village. Because of this, South African Police Service arrived to secure the area while construction workers did their job. 

Meanwhile, South African homeowners are typically warned by the government against illegally constructing homes and other structures. For safety reasons, once the homes are discovered, they are demolished.