A 66-year-old man is evaluated in the emergency department for increasingly difficult-to-manage behaviors. According to his son with whom he lives, he has exhibited intermittent forgetfulness, gotten lost while driving on familiar routes, and had brief but frequent periods of nonsensical speech, excessive daytime sleepiness, and an inability to use familiar objects during the past year. Over the past 3 months, the patient has had increasing visual hallucinations and paranoia accompanied by agitation and restlessness. Medical history is significant for mild depression. His only medication is sertraline. A depression screen is negative for a depressed mood.

On physical examination, temperature is 36.8 °C (98.2 °F), blood pressure is 135/70 mm Hg, pulse rate is 80/min, respiration rate is 16/min, and oxygen saturation is 98% on ambient air. General physical examination findings are normal. Neurologic examination shows an agitated man with masked facies, a soft voice, postural instability, and a slow gait. He scores 24/30 on the Mini-Mental State Examination, missing points on orientation to time and place, delayed recall, and figure drawing.

The patient is given haloperidol in the emergency department to treat the agitation, which results in worsening agitation and limb and neck stiffness.

Which of the following is the most likely diagnosis?