A mahout tried to separate the two animals by poking one with a sharp-edged hook, causing the elephant to run away in pain late Friday, a police official said.
"The elephant did not harm anyone, it was trying to get away from the mahout, but people panicked and started running," a local police official told AFP by phone.
The Hindu temple in Ratnapura, 100 kilometres (60 miles) south of Colombo, was packed with devotees ahead of an annual pageant.
"The situation was quickly brought under control," he added.
Also Read
The country's wild elephant population had dropped to 6,000, from some 7,379 five years ago, largely due to farmers encroaching on their natural habitat.
The number of domesticated elephants has also dropped considerably as the authorities no longer grant permits for the capture of animals from the wild.
Disclaimer: No Business Standard Journalist was involved in creation of this content