In Star Trek: The Next Generation, Dr. Noonien Soong had developed a chip containing a program that would allow his android 'son' Data to experience emotions. In the fourth season episode "Brothers", Soong has recalled Data in order to install the emotion chip, but Data's malevolent brother Lore steals the chip for himself.
In the two-part episode "Descent", Lore is able to transmit a portion of his emotional program to Data and uses it to control him and corrupt a group of renegade Borg. Thanks to the efforts of Captain Jean-Luc Picard and his officers, Lore's control over Data is disrupted and Data fights back. Lore is later deactivated and Data removes the emotion chip, which was damaged when he shot Lore. Data experiences sensations of guilt over torturing his crewmates while under Lore's influence and prepares to destroy the emotion chip, but Geordi La Forge convinces him to keep it until he feels ready to use it.
Data finally decides to install the chip in Star Trek Generations, following an incident on the holodeck where he pushed Dr. Crusher into the ocean because he thought it would be funny. After installing the chip, he and Geordi visit the Enterprise's Ten Forward lounge and Data tries a new beverage that Guinan is serving. He does not understand his reaction at first, but Guinan sees that he hates the drink. Data realises his disgust and excitedly orders another glass. Later, Data and Geordi are investigating the derelict Armargosa Observatory in search of trilithium, and Data lets his newfound sense of humour overwhelm him. He struggles to stop himself laughing and his emotion chip fuses to his neural net, meaning it cannot be removed or deactivated. The investigation of the observatory is interrupted when the scientist Dr. Tolian Soran ambushes Geordi, knocking him out. Data experiences fear for the first time and is immobilized by his terror, failing to act when reinforcements arrive from the Enterprise-D to stop Soran. Soran is picked up by a Klingon ship and escapes with the unconscious Geordi, leaving Data stricken with guilt. Captain Picard denies Data relief from duty, telling him that he needs to learn how to incorporate his emotions into his daily life. Data continues to experience various emotional states, such as bravery when he requests being exchanged for Geordi to the Klingons, relief when Geordi is returned, and even cries tears of joy after finding his cat Spot alive and well following the Enterprise's crash landing on Veridian III.
In Star Trek: First Contact, Data is able to turn his emotion chip on and off at will, as he demonstrates when the crew of the Enterprise-E investigate the Borg's steady assimilation of the ship. After being captured by the Borg and introduced to their queen, Data's emotions are forcibly reactivated. The Borg Queen attempts to manipulate Data by appealing to his emotions, such as exciting him with tactile pleasure after grafting organic skin to his arm, causing him physical pain and seducing him sexually. Although the queen was able to use Data's emotions against him, she could not control him and he feigned loyalty to her so he could get close to the warp core and smash open a plasma coolant tank, leaking coolant gas into Engineering and melting the queen's (and his own) flesh off, killing her and, as a result, killing every Borg on the ship.
Ever since his experience with the Borg, Data has removed the emotion chip in order to prevent anyone else from using his feelings against him or his crew. While he does not feel emotions as he did before, Data has developed a greater understanding of them and still expresses some mannerisms that resemble an emotional response.