Here's the wikipedia definition of octane rating:
The octane rating of a spark ignition engine fuel is the knock resistance (anti-knock rating) compared to a mixture of iso-octane (2,2,4-trimethylpentane, an isomer of octane) and n-heptane. By definition, isooctane is assigned an octane rating of 100 and heptane is assigned an octane rating of zero. An 87-octane gasoline, for example, possesses the same anti-knock rating of a mixture of 87% (by volume) iso-octane and 13% (by volume) n-heptane. This does not mean, however, that the gasoline actually contains these hydrocarbons in these proportions. It simply means that it has the same autoignition resistance as the described mixture.
A high tendency to autoignite, or low octane rating, is undesirable in a spark ignition engine but desirable in a diesel engine. The standard for the combustion quality of diesel fuel is the cetane number. A diesel fuel with a high cetane number has a high tendency to autoignite, as is preferred.
Bottom line - the OCTANE RATING is a means of measuring the tendency for fuel to cause autoignition, or what most people think of as knocking. In a diesel engine, autoignition is good. In our engines, autoignition is bad - we want the fuel to ignite when the spark plug fires, and not before. Most people have the misconception that higher octane fuels generate more power - but that is just a myth willingly perpeturated by auto manufacturers and fuel companies. A lot of other factors go into generating more power - like higher compression - which then require higher octane rated fuels to prevent undesirable premature ignition.