As the president approached the train station, his assassin waited inside, pacing nervously, a revolver in his pocket. James Garfield was about to leave Washington for New Jersey to meet his wife and daughter for his first presidential vacation. Born in a log cabin in Ohio, Garfield, 49, had been a carpenter, a teacher, a lawyer, a Union general and a Republican congressman before he was elected president in 1880. Now, on the morning of July 2, 1881, he strolled into the Baltimore & Potomac station with two of his four sons.

Watching Garfield closely, Charles Guiteau pulled out his revolver. Guiteau was a crooked lawyer, a failed evangelist and a lunatic who believed that God had commanded him to kill Garfield in order to “unite the Republican party and save the Republic.” He stepped behind the president and fired two shots. The first bullet sliced Garfield’s right arm. The second slammed into his back and broke two ribs before lodging in fatty tissue behind his pancreas.

Garfield fell to the floor, bleeding profusely, and the gunman was immediately apprehended. Within minutes, doctors arrived and moved the president, first to a room in the station and then, by horse-drawn ambulance, to the White House. There, doctors probed the wound in his back, searching in vain for the bullet.

The first bullet sliced Garfield’s right arm. The second slammed into his back and broke two ribs

Alexander Graham Bell was visiting his in-laws in Boston when he learned that Garfield had been shot and that doctors couldn’t find the bullet in his torso. Already famous for inventing the telephone, Bell, 34, immediately began pondering how to locate the bullet. Years earlier, while working on telephone technology, he had accidentally discovered an electronic method of detecting hidden metal. Now, he set to work, trying to create a machine that could find the bullet inside the president.

Meanwhile, Garfield lay in a White House bedroom, under the care of a physician with the unlikely name of Dr. Doctor Willard Bliss. (His parents had named him “Doctor” to suggest a career path.) A childhood acquaintance of the president, Bliss served as a Union Army surgeon before practicing medicine in Washington, where he advertised a South American herb called cundurango as a “wonderful remedy for Cancer, Syphilis, Scrofula, Ulcers, Salt Rebum and All Other Chronic Blood Diseases.”

Again and again, Bliss searched for the bullet by sticking his unwashed fingers and unsterilized instruments deep into Garfield’s wound. He should have known better: Joseph Lister and other scientists had already proved that infections were caused by germs and could be prevented by antiseptic practices. But Bliss was among the many American doctors who pooh-poohed the notion that tiny invisible bugs could cause infections. He was wrong, of course, and his unsterilized probing of Garfield’s wound caused an infection that spread to the president’s bloodstream.

In Boston, Bell worked on his metal detecting machine—he called it an “induction balance” device—and wrote to Bliss, volunteering his services. Bliss summoned the famous inventor to the White House in mid-July to discuss the machine, but he didn’t immediately permit Bell to test it on the president. Bell returned to his Washington laboratory, where he kept tinkering with his invention, testing it on Civil War veterans who carried bullets in their bodies. Sometimes his device detected the bullets, sometimes it didn’t.

Weeks went by and Garfield grew sicker. The president was conscious and surprisingly cheerful, but his wound oozed vile yellow pus and his fever spiked to 104 degrees. Bliss, who’d been issuing optimistic medical bulletins for weeks, worried that his famous patient might die. On July 26 the desperate doctor wrote to the inventor.

“Would you do us the favor to call at the Executive Mansion at about 5 p.m. today,” Bliss asked Bell, “and work the experiment with the Induction Balance on the person of the President?”

Bell came to the White House and set up his machine. It was a strange-looking device with a wooden handle, a battery, a condenser and a telephone receiver that Bell held to his ear to listen for the sound made when the device detected metal. But when he tested it, he heard a strange sputtering noise in the receiver. Before he could correct that problem, Bliss summoned him into Garfield’s room. Bell was shocked at the president’s ashen color. “It made my heart bleed to look at him,” Bell wrote, “and think of all he must have suffered to bring him to this.”

The president asked Bell a few questions about the device. Satisfied with Bell’s answers, Garfield consented to the test. Attendants rolled him onto his left side and he leaned his head on an aide’s shoulder while Dr. Bliss removed the dressing over his wound.

The test began: Bliss passed Bell’s device over the president’s back, while Bell held the receiver to his ear. But the sputtering sound in the receiver made hearing difficult. Bell detected sounds but they were “uncertain and indefinite,” and he failed to locate the bullet.

“I feel woefully disappointed & disheartened,” Bell wrote to his wife that night. He felt even worse the next morning when he realized that he had caused the sputtering sound by assembling his machine improperly in the White House.

Garfield grew sicker, and Bliss summoned Bell back to the White House. Bell arrived for his second visit on August 1, confident that his machine was functioning better than ever.

This time, Bliss insisted that Bell test only the right side of Garfield’s body, where Bliss was certain the bullet lay. Holding the receiver to his ear, Bell heard a sound but it was weak and it didn’t resemble the usual noise made when the machine detected metal.

Bliss informed reporters that Bell’s machine had confirmed his belief that the bullet was on the lower right side of the president’s torso. But Bell wasn’t so sure. He wondered if perhaps there was some metal in the president’s bed that interfered with the test. He went to the White House the next day and learned that the president lay on a mattress “composed of steel wires.”

Bell obtained an identical mattress. When he passed his machine over it, he heard the same odd sound he’d heard when examining Garfield. Obviously, his machine had detected the wires, not the bullet.

Bell was eager to try again, but he never got the chance. On September 19, after 79 days of agony, James Garfield died of septic poisoning that was almost certainly caused by Bliss’ repeated unsanitary probing of his wound. An autopsy revealed that the bullet was on the left side of his torso, not on the right, where Bliss insisted that Bell look for it.

“Garfield died from malpractice,” proclaimed Guiteau, the man who shot the president. He had a point, but the jury convicted him anyway. After he was hanged in 1882, doctors chopped his brain into cubes, searching for the source of his madness. They didn’t find it.

Meanwhile, Bell continued tinkering with his induction balance machine, ultimately creating a device used for decades by battlefield surgeons searching for hidden bullets in wounded soldiers.

Originally published in the February 2016 issue of American History magazine.