You probably had an abscess (pocket of pus) that originated in one of the tiny glands that lie just inside the anal canal. The infection made its way beyond the anal canal and into the skin around the outside of the anus.
Often, after the abscess breaks opens and drains, the infection can create a thin tunnel-like passageway. This path between the anal canal and the outside anal skin is called anal fistula. The fistula usually surrounds at least part of the anal sphincter muscle.
An anal fistula can be almost unnoticeable, except for the sporadic drainage of a little pus or blood from the external opening. There can also be a slight tenderness in the area. Sometimes the external skin temporarily heals, but the underlying fistula stays. This means the abscess may repeatedly form and then drain again.
Anal fistulas are not dangerous, but once they form, they probably will not heal permanently without surgery. Most commonly, surgery is done to open the fistula track.
Surgery to remove the "roof" of the fistula tunnel is the most effective therapy. Your doctor opens the infected canal and scrapes away any remnants of the old anal abscess. The wound is left open to heal from the bottom up.
Since most fistulas surround part of the anal sphincter muscle, opening the fistula involves cutting part of the anal sphincter muscle. Unless the fistula is deep, there is usually no major effect upon continence (control of stools). Some people, however, do notice minor incontinence. There may be some seepage of stool if the person has diarrhea, or they may have difficulty controlling gas. Often this minor incontinence improves with time.
If an anal fistula is deep, and surrounds a significant portion of the anal sphincter muscle, then the risk of greater incontinence after surgery is higher. Also, multiple operations, and/or operations that are more complex may be required. Fortunately, the need for this is unusual.