The power to the fence was reportedly switched on using a switch operated by a rope, only when elephants came near the farm.
As Ramaiah, the farm-owner, noticed the elephant, he pulled the rope, which was wet due to rains for the last couple of days and it came into contact with the 'live' fence and he was electrocuted, police said.
The elephant, which attempted to enter the farm, also was electrocuted.