Trading is an interaction between the player and villagers, which was added in the 1.3.1 update. It is done by right-clicking a villager in the PC version of Minecraft. Trading is currently not available in Windows 10 Edition or Pocket Edition. Baby villagers cannot trade.
How To trade
Each villager starts out with a single option to trade for something. For the purposes of this explanation, they will be referred to as "trade agreements", or simply "agreements." Each trade agreement can be done a number of times before the villager no longer wants to honor it. This is usually five times, but may vary. Completing the first trade agreement and then closing the trade window or interface, will cause the villager to enter a "thinking" mode, and give the villager an increased reputation with the player (reputation further explained below).
A villager can have up to five trade agreements at one time, though it can replace old ones with new ones after the fifth. The only way to unlock more agreements is to trade with the villager, completing at least one agreement each time. Once five trade agreements have been reached, continuing to trade the final agreement will still reset the other agreements, allowing more trading, but also have a chance of replacing the current agreements with yet another new agreement.
Special "Cartographer" villagers were added in The Exploration Update. Players can trade with these cartographers, who are willing to trade an Exploration Map, for a combination of emeralds and a Compass.
In mulitplayer servers with NPC villagers built-in to villages, players may act as highwaymen, or robbers, and kill players they believe may have just traded a villager for emeralds.
A villager will "like" a player more, the more times they trade with each other. This is useful for only one purpose: to stop the town's Iron Golems from attacking the player. Golems usually only become hostile when the villagers are angry, because they were recently attacked by the player. Alternatively, the player may escape the village and wait for a while before returning. Hostile Iron Golems will eventually forgive/forget the player. Trading is usually difficult unless done indoors, while Iron Golems are present and the villagers are angry with the player.
- In the PS3 version, enchanted weapons cannot be traded to a villager, only ones without enchantments.