The Vinaya is the textual framework for the Buddhist monastic community, or sangha. The teachings of the Buddha, or Buddhadharma can be divided into two broad categories: 'Dharma' or doctrine, and 'Vinaya', or discipline. Generally speaking the former is concerned with theory, and the latter with practice, although there is actually considerable cross-over between the two. Another term for Buddhism is dharmavinaya.
At the heart of the Vinaya is a set of rules known as Patimokkkha (Pali), or Pratimoksha (Sanskrit). In the Theravadin tradition there are 227 rules for the bhikkhus (male monastics), 311 for the bhikkhunis (females). Other traditions have differing numbers of rules, for example the Gelugpa order of Tibet follow a vinaya originally belonging to the Sarvastivadin sect and which has 253 rules.
Surrounding the rules is a range of texts. Some of these explain the origins of rules - it is possible to trace the development of rules from responses to specific situations or actions, through to a general codification. There are also a number of sutta like texts which are more general statements about Buddhist doctrine, or which give biographical details of some of the great disciples and their enlightenment. Other sections detail how the rules are to be applied, how breaches are to be dealt with, and how disputes amongst the monks are handled.
It is thought that originally there were no rules and the Buddha and his disciples just lived in harmony when they were together. Most of the time they would have been wandering alone, but every year, during the monsoon season when travelling became impossible, the bhikkhus would come together for a few months. As the sangha became bigger and started accepting people of lesser ability who remained unenlightened, it became necessary to begin having rules.
It seems that initially these were quite flexible and were adapted to the situation. By the time of the Buddha's death there would have been a body of rules which bhikkhus were expected to follow. Some of these have a positive ethical charcter such as abstaining from taking things not freely offered. However many of the rules related to setting up conditions for spiritual practice and have no real ethical value, such as the rule about refraining from taking more than one meal per day, and that before noon.
In the Mahaparinibbana _Sutta the Buddha, as part of his last teaching, tells the bhikkhus that they can abandon any of the minor rules, but that they should stick to the major ones, but there appears to have been some confusion over which was which. It was therefore decided that they would keep all of the rules. Immediately after the Buddha's death there was council at which all of the teachings were recited, collected and sorted. Legend has it that the huge volume of teachings were recited from memory, with Ananda reciting the suttas and Upali reciting the Vinaya.
See also Sangha