Sparkles answer would be an apt response here in the western U.S. A chimney fire occurs when the soot build up catches fire itself. Usually, (here, at least) burning pine type firewoods contributes significantly to the possibility of a fire, due to the oils and incomplete burning in that type of wood.
The phenomena is often accompanied by an outpouring of significant black smoke as well as the sparks. If the chimney is lined with and adequate liner the fire won't hurt the structure, but, if the chimney is an older brick and mortar structure (even cement block and mortar) a really serious fire can begin burning the mortar, which has a higher lime content and can burn through to the supporting roof structure.
As already mentioned, good chimney cleaning on a regular schedule will eliminate most problems, but to really assure no such occurrence, installation of a stainless steel, insulated liner is a must… but somewhat expensive, depending on the height of the chimney…
Another, interim safety item is a chimney fire extinguisher. They (at least here) consist of a cylinder about 1 1/2 inches in diameter and maybe 14 to 16 inches long and contains an extinguishing agent that eliminates oxygen to the fire. One simply throws it into the burning fireplace or insert where it ignites. They work pretty well, but don't take the place of an updated chimney...