This tutorial is for linux users.
1. Install imagemagick with this command -
sudo apt-get install imagemagick
2. Set Blender up to render animations to png images (or similar) instead of a video format.
3. Make sure the colour is set to RGB not RGBA.
4. Press Animate.
5. Go to the default render directory (this will be /tmp in linux) where you should find a lot of png files.
6. Type this command to create your gif from those pngs -
convert -delay 4 -loop 0 *.png animated.gif
7. Enjoy your new animated gif.

Note - the delay setting refers to 1/100ths of a second. so in the example above 4/100th = 25fps.