Could you give us an update on your cat's condition? What did the vet say? From your description it sounded like an anal prolapse, for which only a vet can fix, as it may need surgical attention. The cat may be in a lot of pain, and DO NOT try pushing it back in yourself.
After this has been taken care of, please ask the vet how you can add fiber or get fiber-added foods for your cat, and have him drink more water. There are also excellent suggestions on these boards, just do a search. FYI for others, although there are different causes for this, the main one is not enough fiber in an unbalanced diet.