In an experiment participants opted to kill one person if it meant saving the lives of five others.
Researchers at the Michigan State University, USA, put participants in a 3D setting and stationed each participant at a railroad switch where two sets of tracks veered off.
Up ahead and to their right, five people - shown through realistic, digital characters - hiked along tracks and a runaway boxcar sped toward them. They couldn't move out of its tracks due to a steep ravine. On the opposite side, a single person hiked along in the same setting.
Participants were given the choice to either do nothing or pull the joystick that would reroute the boxcar to the tracks occupied by the single hiker.
About 90 per cent of the subjects pulled a switch to reroute the boxcar, suggesting that people are willing to violate a moral rule if it means minimizing harm.
"What we found is that the rule of 'Thou shalt not kill' can be overcome by considerations of the greater good," said Carlos David Navarrete, lead researcher on the project.
"I think humans have an aversion to harming others that needs to be overridden by something... by rational thinking we can sometimes override it - by thinking about the people we will save, for example," he said.
The results of the study were published in the research journal Emotion.