Up to 150 veterans with the diagnosis of major depressive disorder or bipolar 1 or 2 older than 18 years of age undergoing ECT will be randomized and blinded to the intervention. Operative ECT clinicians will not be blinded; clinicians evaluating patients will be blinded. Exclusion criteria for this study include uncontrolled hypertension, blood pressure > 180/90 mmHg at the pre-anesthesia clinic visit, renal failure, neurologic disorders (e.g. epilepsy, space occupying lesions, traumatic brain injuries in the past 6 months), myocardial infarction in the past 6 months, known allergies or adverse reactions to ketamine, American Society of Anesthesiology Physical Class greater than 3, concomitant psychosis, schizophrenia or current abuse of alcohol or illicit substances and pregnancy.