"With the exception of certain disability assistance devices, overhead bins or under seat stowage space is available to all passengers and crew members for their carry-on baggage on a “first come, first served” basis. Accordingly, carriers are not required to remove other passengers’ or crew members’ carry-on baggage that is already stowed in order to make space for a musical instrument. However, this also means that carriers are not allowed to require a passenger to remove his or her musical instrument that is already safely stowed (e.g., in the overhead bin) to make room for carry-on baggage of other passengers who board the aircraft later than the passenger with the musical instrumenT." Most importantly, "This is true even if the space taken by the musical instrument could accommodate one or more other carry-on items." You can read the entire text of the rule here.
The DOT has also provided a helpful page with links to procedures for complaining to an airline or to the DOT regarding air travel with instruments, and tips for traveling with a musical instrument, available here.
One problem is that on any given day a random gate agent might be having a bad day and decide that he or she does not want to permit your guitar to go on with you as carry-on - and, as a practical matter, there is not a lot you can do in that situation (otherwise, if you get defensive or even ornery, you run the risk that security will be called, etc.). Consider that particular dilemma a bit of bad luck.
Best advice? Print a copy of the rule and carry it on with you when you travel so you can stop arguing with that officious ticket agent who insists that you have to check your guitar as baggage or buy another seat for it.
Wallace Collins is an entertainment and intellectual property lawyer based in