BERLIN (Reuters) - Protecting people rather than property or animals will be the priority under pioneering new German legal guidelines for the operation of driverless cars, the transport ministry said on Wednesday.

Germany is home to some of the world's largest car companies, including Volkswagen <VOWG_p.DE>, Daimler <DAIGn.DE> and BMW <BMWG.DE>, all of which are investing heavily in self-driving technology.

German regulators have been working on rules for how such vehicles should be programmed to deal with a dilemma, such as choosing between hitting a cyclist or accelerating beyond legal speeds to avoid an accident.

Under new ethical guidelines - drawn up by a government-appointed committee comprising experts in ethics, law and technology - the software that controls such cars must be programmed to avoid injury or death of people at all cost.

That means that when an accident is unavoidable, the software must choose whichever action will hurt people the least, even if that means destroying property or hitting animals in the road, a transport ministry statement showed.

The software may not decide on its course of action based on the age, sex or physical condition of any people involved.

"The interactions of humans and machines is throwing up new ethical questions in the age of digitalization and self-learning systems," German Transport Minister Alexander Dobrindt said in a statement.

"The ministry's ethics commission has pioneered the cause and drawn up the world's first set of guidelines for automated driving," he added.

Germany earlier this year passed legislation under which a driver must be sitting behind the wheel at all times ready to take back control if prompted to do so by the autonomous vehicle, clearing the way for the development and testing of self-driving cars.

(Reporting by Maria Sheahan; Editing by Keith Weir)