Electric organs evolved eight separate times, mostly from ordinary muscle
Some 350 fish species can generate electric fields, and they did not inherit the trick from one ancestor. Electric organs arose independently eight times, built mostly from modified muscle cells. Some fish use the charge to see in murky water, some to chat, and a few, like the electric eel, to stun.
Every animal with nerves runs on electricity, but electric fish go further, using a dedicated organ made of electrocytes, reworked muscle or nerve cells. Discharges come as pulses or continuous waves and serve to find prey, deter predators and signal, including during courtship. Weakly electric species produce under a volt, far too little to hurt anything, and use it with receptors in their skin to navigate and communicate. The main groups are Africa's elephantfishes and the South American knifefishes, which evolved these abilities independently and use different receptors and organ placements.
Sensing electricity is much older than making it. The last common ancestor of vertebrates had ampullae of Lorenzini, electrical sensors derived from the lateral line, still found in sharks, rays, lungfishes, sturgeons and some amphibians. Most bony fish lost them early, and where electroreception reappeared it used new, unrelated organs. The platypus and echidna evolved passive electrical sensing on their own. Of the eight origins of electric organs, four produce shocks strong enough to matter, and one knifefish family built its organ from nerve rather than muscle tissue.
Body shape tells part of the story. Some species incorporate trunk, tail and even eye muscles into the organ, or have lost most of the tail fin, which seems to keep the body stiff so the field stays steady while swimming. Species living in open habitats show these traits less, suggesting that electrolocation drove their evolution.
The behaviour is surprisingly sophisticated. The African sharptooth catfish eavesdrops on the signals of its elephantfish prey, pushing them toward harder-to-detect pulses. A bluntnose knifefish mimics the electrical signature of the dangerous electric eel. Glass knifefish that find themselves broadcasting on similar frequencies each shift up or down to avoid jamming. Among the strong shockers, electric eels can even leap from the water to press a charge directly onto a threat, and stargazers are the only shock-producers that lack electrical sensing altogether.
Source: Electric fish