Just the right amount of audio feedback from the amplifier back to the guitar. If you do it right, it doesn’t squeal or shriek, it just keeps your note going, as long as you want.
Oh and BTW, if you’re good at it, by subtly changing how you position the guitar relative to the amplifier, you can alter the relative amplitude of the various harmonics, and get the note to shift up one or even two octaves, and come back down. It’s a gorgeous effect, and doesn’t require any electronics other than lots of gain, although overdrive can be helpful in smoothing out the transitions.
And volume. I have a Marshall Plexi half stack and every now and then I'll get a wild hair up my ass and dime it out. It shakes the walls. Standing in the right place though, I can hold a note forever.