Anesthesia is the use of medicine to prevent the feeling of pain or another sensation during surgery or other procedures that might be painful. Given as an injection or through inhaled gases or vapors, different types of anesthesia affect the nervous system in various ways by blocking nerve impulses and, therefore, pain.