Guruvayur temple was being managed by the Zamorin of Calicut ( in association with Mallisseri illam) till the State Government took over the management of the temple in 1971. The temple is known for its strict adherence for the tantric rites as much as for its unique rituals. One of the interesting rituals is the elephant race on the first day of the temple festival which falls on pushya star in the Malayalam month of Kumbha (falling in the 3rd or 4th week of February).
How did the elephant race begin? There is a story which relates this ritual to the rivalry between Zamorin and the King of Cochin. It seems Guruvayur was once under the Trikkanamathilakam temple and did not own any elephants. The practice was for the elephants which were paraded in the Trikkanamathilakam temple festival to be loaned to the Guruvayur temple where the festival was usually held a couple of days later. 
There was once some misunderstanding between the authorities of the two temples and Trikkanamathilakam temple authorities wanted to teach the smaller Guruvayur temple a lesson by not sending the elephants for the festival. The elephants were tethered at the Trikkanamathilakam temple after the festival there. 
Apparently, the elephants managed to break the iron chains at night and ran all the way to Guruvayur temple, with their bells clanging and reached the temple well before the time for the ezhunnallathu  (the ceremonial procession of the deity). In order to commemorate this event, an elephant race is conducted on the first day of the annual festival in Guruvayur. Further, the morning ezhunnallathu on the first day is conducted without elephants - the only day when the priest carries the idol and walks around the temple, unlike the usual ritual of the priest riding an elephant with the idol.
the race in progress
Trikkanamathilakam temple was destroyed by the Dutch in 1755 and it was no longer a rival to Guruvayur which prospered by the day and has now more than 50 elphants housed in the majestic Punnathoor Kotta. However, only about half a dozen selected elephants are allowed to participate in the race (for reasons of safety) which starts from the Manjulal banyan tree and ends inside the temple after taking a round of the main shrine. The winning elephant is treated royally and has the privilege of carrying the idol for that year.
When did this strange custom begin? Is there any truth in the legend that it was started due to the denial of elephants to Guruvayur by Trikkanamathilakam management? There are no records available.
However, in a recent issue of Bhakthapriya (March 2014), some historical documents have been reproduced. (These documents belonged to the Zamorin's palace in Thiruvachira, Calicut and have now been recovered and preserved thanks to the perseverance of Dr. N.M Namboodiri, the renowned toponymist).
There is an entry dated 7th January 1928 which is a letter, detailing the preparations needed for the annual festival, from the Manager of Guruvayur Temple to the Zamorin: "... the temple elephant Padmanabhan having dead, we have no elephant for the ezhunnallath. We do not usually hire elephants for this purpose and it is difficult to get big elephants without payment. There are four fairly grown up elephants in this neighbourhood under the ownership of Punnathur and Ullanatt Panicker. We hope these elephants will be made available. We have written to some others including Kothachira mana. However, these elephants coming from outside need to be fed and their mahouts paid salaries. The estimate sent herewith includes these additional costs also."
Notice that there is no mention of either the Anayottam or the ritual of an ezhunnallathu without an elephant. More significantly, some 86 years ago, Guruvayur temple had only a solitary elephant and the temple authorities were reluctant to get elephants from outside, as they had to be paid for.
It is clear that the ritual of Anayottam was not there even as late as the second decade of the 20th Century.