I don't know how true this is but it dates back to cowboy and indian times. A certain tribe of indians were captured by cowboys. The cowboys cut their middle fingers off because they used it to shoot their arrows at the cowboys.
One day they captured another set of indians. By now word got out to the indians about what the cowboys were doing. A few indians in hiding waited for the right moment to rescue their comrades. Once they were rescued they ran off all together wagging their middle fingers at the cowboys.