1. Originating in Old Europe during the Middle Ages, where burial space was often in short supply throughout many communities. To maximize use of space in many cemetaries, the dead were often buried in a 6 foot vertical shaft, rather than the usual horizontal grave position. The vertical position was considered less socially respectable. Thereafter the term began to mean poor treatment given to someone in such a way that demeans him or affirms second hand status as a citizen.
In communities that had active, but hidden, homosexual communities, the phrase took on a second meaning in double entendre, referring to the humiliating prospect of having to bend over, grab one's ankles, and recieve painful anal intercourse from someone who is overly aggressive and abusive.
When they fired Bob, they gave him the shaft.