Clocking in at 338 minutes, the black-and-white film from director Lav Diaz beat 16 other films to the festival's top prize, the organizers said in a statement.
"From What Is Before" recounts the strange events that befall an isolated village in the Philippines in 1972 during the era of the dictator Ferdinand Marcos, when brutal militias roamed the countryside.
Now in its 67th year, the Locarno festival takes place every summer in the picturesque Swiss town on the shores of Lake Maggiore.
The runner-up Special Jury Prize went to "Listen up Philip" by US director Alex Ross Perry. Portugal's Pedro Costa won best director for "Cavalo Dinheiro" ("Horse Money").
There were also awards for actor Artem Bystrov for his part in the Russian film "Durak" ("The Fool") and French actress Ariane Labed for "Fidelio (the Odyssey of Alice)".