Imagine a job that demands vigorous detective work seven days a week and most holidays but comes up empty three-quarters of the time. A job that’s infinitely engaging but deals with people who are desperate and in chronic pain. Most will not get better.

This is the world inhabited by William A. Gahl, clinical director of the Undiagnosed Diseases Program at the National Institutes of Health. For thousands of patients with mystery illnesses, Gahl’s 10th-floor office in the NIH Clinical Center in Bethesda is the end of the line — if they are lucky enough to get there.

There is Sally Massagee, an accountant and mother of five from North Carolina whose muscles bulked up so uncontrollably that lifting her arms to put on a turtleneck was unbearable. And Reece LoCicero, a Los Angeles boy who has been in and out of hospitals for most of his 5 years with skin sores, internal bleeding, asthma and meningitis.

Then there was Summer Stiers, whose seizures, partial blindness, intestinal bleeding and failing kidneys went undiagnosed in 20 years of visits to specialists near her home in Oregon. Stiers died in June 2009, seven months after Gahl’s team of scientists met her and took samples of her blood, skin and DNA. But she was no closer to an answer for her symptoms.

Massagee’s mystery was solved, one of the success stories since the program was launched in 2008 as a $280,000 pilot. The culprit, discovered through genetic testing, was an abnormal accumulation of proteins called amyloids that was moving to attack her other organs. A grueling stem cell transplant made her healthy.

LoCicero’s parents, who took him to NIH last month, are waiting for scientists to pore through the slides, ultrasound, skin biopsies and blood work collected during his five-day visit.

“We have a lot of in­cred­ibly sad cases,” Gahl, 61, said in his small corner office, which is strewn with medical files of the program’s 463 patients. Behind each of the many windows on his Macintosh screen is a case: A woman in her 30s whose face gets flushed so badly she needs to be cold for relief. A 34-year-old man with painful lesions all over his body who lost his right hand to gangrene. Two teenage brothers with paraplegia, poor balance and seizures whose parents are first cousins. One brother died of pneumonia before his NIH work-up, which uncovered a gene mutation. But a treatment for the other boy is far away.

“They see us as a sort of last ditch,” Gahl said of his patients. “They’re appreciative of the fact that we’re trying, even though we fail most of the time.”

The nonprofit Partnership for Public Service called the biochemical geneticist “America’s leading medical sleuth” when it named him one of four finalists for this year’s Samuel J. Heyman Service to America Science and Environmental Medal. His job mixes the compassion of a clinician with the wonder of a research scientist, and requires endless patience.

“He’s a people person, and yet he’s so fascinated with the science,” Massagee said. “When I talk to him, it’s the same conversation he would have with a doctor that he has with me.”

It’s a day-to-day balance between saving lives and advancing science. About 6,600 human diseases have been identified, and most doctors are unlikely to run into more than a fraction of them. About 5,500 inquiries about the Undiagnosed Diseases Program have come in; 2,000 patients have competed for a spot, mostly through referrals from their doctors. About 80 percent are rejected.

“You’re going to leave people on the battlefield, but if you think too much about that you’re through,” Gahl said.

The program is designed to go beyond the organ-centered focus of most medical specialties, to get a more holistic view. Gahl and his 30-member staff bring together scientists from all over the NIH, the country’s top medical research institute. Every patient is seen for free, a luxury of the government that is rare in private research settings. Insurance and drug companies “don’t have a focus that’s uninfluenced by profit” when it comes to diseases that afflict just 200,000 patients a year, Gahl said.

Patients arrive Monday and leave Friday after an extensive clinical work-up. But much of the real work begins once they leave, when the scientists try to define their illnesses by DNA defects that could explain the problems. This can take months.

Gahl is a compact man with thinning gray hair and frameless aviator glasses. He has a dry wit, learned from his Wisconsin childhood. He describes his job, for example, as a career stopper. “You have to be a little washed up to do things like this,” he joked.

He is far from washed up, and a fierce advocate for his patients.

Gahl arrived at NIH in 1981 as a fellow in the new field of medical genetics. After a career researching rare diseases, he has several roles that include clinical director of the National Human Genome Research Institute, which in 2003 celebrated the completion of the human genome sequence, decoding the genetic instructions found in a human cell.

Cynthia Tifft, the pediatrician and geneticist who handles the program’s pediatric cases, calls Gahl “hysterically funny” yet “intense about anything he takes on.”

This includes a lifelong devotion to softball, which he plays several nights a week on an over-60 league in Montgomery County. His nickname on the field is Dr. Dirt. “He always slides into base because it’s quicker,” said his wife, Mary. They married in college, have four grown children and live in a modest house in Kensington. “He still thinks he’s young,” she joked.

One of Gahl’s gifts is working the system for his patients. The program’s start three years ago was followed by an avalanche of news coverage, and the small staff was overwhelmed with submissions. Gahl told NIH leaders the program should close the door to new patients because he wasn’t doing anyone justice. The NIH came up with $3.5 million a year through fiscal 2012. “A lesson in how to get things done,” he recalled. As of July 1, though, he stopped accepting new patients to focus on existing ones.

There have been notable successes. Five siblings in a Kentucky family came to Bethesda barely able to walk, with calves as hard as rocks. Blood vessels in their legs, feet and hands had developed calcium deposits that prevented the flow of blood. Because every child in the family was affected — but the parents were not — Gahl and his team took a genetic approach, thinking the disease might be caused by a recessive gene.

They were right. Nine people from three families are now known to have the newly discovered disease, and Gahl is seeking Food and Drug Administration approval to treat them with an osteoporosis drug similar to Boniva that regulates calcium in the body.

Treatment is not a given when the scientists make a diagnosis. The FDA demands controlled trials and lengthy animal toxicity tests before it will approve a drug, and rare diseases, because they affect relatively few patients, do not rise to the top of the list. Earlier this year, Gahl’s team identified an enzyme that could help a 5-year-old boy who cannot produce myelin recover from painful internal bleeding. He is the only known patient in North America with the genetic disorder.

The multiple studies required by the FDA will cost $1.5 million. Even if he could find funding, Gahl said, the boy will die before they are done. And he is angry.

During a recent lecture to students at Carnegie Mellon University in Pittsburgh, he waved the FDA’s letter from the lectern as he explained the case. He choked up.

“We have potential treatments that make sense with very little side effects, and yet we’re not allowed to use them,” he said. “People in the rare disease community want to be protected, but they don’t want to be protected to death.”