Nepal's president, top officials and diplomats gathered recently at army grounds in central Kathmandu for an annual horse festival that marks the slaying of the Hindu Gurumapa demon.

Soldiers race the horses and show off warfare techniques believed to keep devil spirits away through the pounding of the horses' hooves.

A dedicated team of soldiers spends three months preparing the animals for the Ghode Jatra festival.

According to a centuries-old tradition, people raced horses before worshipping gods with offerings of food and flowers under a tree.

It has been 169 years since a Nepalese king designated the army to perform the festival rituals.

Runners and riders: Grand National 2019 Show all 41 1 /41 Runners and riders: Grand National 2019 Runners and riders: Grand National 2019 Runners and riders: Grand National 2019 LIVERPOOL, ENGLAND - APRIL 08: Derek Fox riding One For Arthur (C) clear the last to win The Randox Health Grand National from Cause Of Causes and Jamie Codd (2R, green) at Aintree Racecourse on April 8, 2017 in Liverpool, England. (Photo by Alan Crowhurst/Getty Images) Getty Runners and riders: Grand National 2019 Outlander 100/1 Runners and riders: Grand National 2019 Just A Par 66/1 Getty Images Runners and riders: Grand National 2019 Livelovelaugh 66/1 Runners and riders: Grand National 2019 Don Poli 66/1 Getty Images Runners and riders: Grand National 2019 Valsuer Lad 66/1 Runners and riders: Grand National 2019 Bless The Wings 66/1 Getty Images Runners and riders: Grand National 2019 Monbeg Notorious 66/1 Runners and riders: Grand National 2019 Regal Encoure 66/1 Getty Images Runners and riders: Grand National 2019 Blow By Blow 66/1 Runners and riders: Grand National 2019 Valtor 50/1 Getty Images Runners and riders: Grand National 2019 Mala Beach 50/1 Runners and riders: Grand National 2019 Magic of Light 50/1 Getty Images Runners and riders: Grand National 2019 Ultragold 50/1 Getty Images Runners and riders: Grand National 2019 A Toi Phil 50/1 Getty Images Runners and riders: Grand National 2019 Warriors Tale 50/1 Runners and riders: Grand National 2019 Captain Redbeard 50/1 Runners and riders: Grand National 2019 Folsom Blue 50/1 Runners and riders: Grand National 2019 Singlefarmpayment 50/1 Getty Images Runners and riders: Grand National 2019 General Principle 40/1 Runners and riders: Grand National 2019 Tea For Two 40/1 Runners and riders: Grand National 2019 Go Conquer 33/1 Getty Images Runners and riders: Grand National 2019 Noble Endeavour 33/1 Runners and riders: Grand National 2019 Dounikos 33/1 Conor Wyse Runners and riders: Grand National 2019 Ballyoptic 33/1 Getty Runners and riders: Grand National 2019 Vieux Lion Rouge 33/1 Getty Images Runners and riders: Grand National 2019 Step Back 25/1 Runners and riders: Grand National 2019 Walk In The Mill 25/1 Runners and riders: Grand National 2019 Ramses De Teillee 25/1 Getty Images Runners and riders: Grand National 2019 One For Arthur 25/1 Getty Images Runners and riders: Grand National 2019 Minella Rocco 25/1 Getty Images Runners and riders: Grand National 2019 Up For Review 25/1 Runners and riders: Grand National 2019 Rock The Kasbah 20/1 Getty Images Runners and riders: Grand National 2019 Jury Duty 18/1 Runners and riders: Grand National 2019 Pleasant Company 18/1 Runners and riders: Grand National 2019 Joe Farrell 16/1 Getty Images Runners and riders: Grand National 2019 Anibale Fly 14/1 Getty Images Runners and riders: Grand National 2019 Lake View Lad 14/1 Getty Images Runners and riders: Grand National 2019 Vintage Clouds 12/1 AFP/Getty Images Runners and riders: Grand National 2019 Rathvinden 9/1 Getty Images Runners and riders: Grand National 2019 Tiger Roll 7/2 Getty Images

At the Nepal Cavalry grounds, located on the former site of the royal palace in Kathmandu, Nepal's capital, riders spend months bonding with the horses.

There are 106 horses at the cavalry and more than 200 soldiers take care of them.

Every day, the soldiers bathe, groom and feed the horses, which are raced and tested to check their skills and ability.

Captain Ram Shrestha of the Nepal Cavalry likened horses to children: "If you love them, they will love you back, but if you abuse them, they will hit back like a bad child."

On the day of the festival, the uniformed riders race the horses on tracks, and show off skills like picking up objects with spears while riding at high speeds.

Meanwhile, the most powerful members of Nepal's government and foreign diplomats cheer them on.

A child revered as the Hindu Living Goddess Kumari is carried out of the palace temple and brought to watch the horse festival.

Away from the cavalry grounds, the Newar community — an indigenous group from Kathmandu — worships the gods and feasts with friends, families and community.