The space enclosed within the external walls of a castle, not including the “Keep.” The entrance was over a drawbridge, and through the embattled gate (Middle-age Latin balium or ballium, a corruption of vallum, a rampart).
When there were two courts to a castle, they were distinguished as the outer and inner bailey (rampart). Subsequently the word included the court and all its buildings; and when the court was abolished, the term was attached to the castle, as the Old Bailey (London) and the Bailey (Oxford).
Source: Dictionary of Phrase and Fable, E. Cobham Brewer, 1894
More on Bailey from Infoplease: