Popular 7th Century legend on King Udayana.
King Pradyota of Ujjain wanted to capture rival king Udayana.
King Udayana was very fond of music and of capturing wild elephants, and Pradyota trapped him by luring him out of the limits of his Kingdom into the pursuit of a faked elephant. Taken captive, Udayana was treated in a right royal manner at Ujjayini, and was requested to teach music to princess Vasavadatta. Love arose at first sight, and Udayana soon excaped with Vasavadatta.
Variations on the legend have it that the Mechanical elephant was built by a local carpenter and contained a mechanical device which enabled it to walk, and in its interior, armed soldiers were hidden. Whilst King Udayana played his lute and followed the mechanical elephant, armed soldiers [a la the Trojan Horse] came out of the elephant at an opportune time and took him as a prisoner to Ujjain City.