A guild // is an association of artisans and merchants who oversee the practice of their craft/trade in a particular area. The earliest types of guild formed as organizations of tradesmen, belonging to: a professional association, a trade union, a cartel, and/or a secret society. They sometimes depended on grants of letters patent from a monarch or other ruler to enforce the flow of trade to their self-employed members, and to retain ownership of tools and the supply of materials, but were mostly regulated by the city government. A lasting legacy of traditional guilds are the guildhalls constructed and used as guild meeting-places. Guild members found guilty of cheating on the public would be fined or banned from the guild.
Typically the key "privilege" was that only guild members were allowed to sell their goods or practice their skill within the city. There might be controls on minimum or maximum prices, hours of trading, numbers of apprentices, and many other things. As well as reducing free competition, but sometimes maintaining a good quality of work. Often these rules made it difficult or impossible for women, immigrants to the city, and non-Christians to run businesses working in the trade. 
An important result of the guild framework was the emergence of universities at Bologna (established in 1088), Oxford (at least since 1096) and Paris (c. 1150); they originated as guilds of students (as at Bologna) or of masters (as at Paris).