FALMOUTH, Maine — Everything finally seemed back on track. David was home for a short visit and looked happy, calm. He had a job, a girlfriend, a plan. His father, Kevin McCarthy, came home from work that Thursday and smiled to see his son take his dog, Kima, named for the drug-fighting detective on “The Wire,” out for a long walk.

When David came back, father and son settled in to watch their Patriots play the Jets on “Thursday Night Football.” David gave his father grief about the TV being too small: “Come on, Dad, get with the 21st century.” Near halftime, David got up and said he was going to watch part of the game at a friend’s place.

When David returned an hour later, they watched the end of the game together. The Patriots won, barely. Kevin went to work the next morning, and he returned home at 4:30 Friday afternoon. It was to be David’s last night at home before he drove up to Sugarloaf Mountain to spend the winter at the family’s ski place, working in a restaurant, his passion.

Kevin, who had moved his family to this splendid spot on the Maine coast after finding the life of a high-powered Manhattan attorney too frazzling, and Nancy, David’s stepmother, had decided against taking David out to dinner on his last night home — there would be too much temptation to drink. Why risk it with David on the good path? So Kevin had gone out, bought a steak and thrown it on the grill.

Then he heard whining from upstairs. Kima, David’s black Lab.

“Dave? Dave!” the father yelled up.

He heard just the dog. He went up, opened the door and saw David’s feet on the floor. His boy was cold.

“It was pretty clear he was dead,” the father said. David was 29.

The needle was on the bed, next to him. The spoon was on the nightstand. A crystalline substance glistened in the spoon.

Kevin tried to revive his son, pumping, pushing, pleading. He called 911. He argued with the operator, who had the location wrong. The operator kept telling Kevin to calm down.

The next 20 hours were a blur of police sirens, ambulances, drug agents, cops, friends and the rest of the family, now coming home for the worst possible reason.

All of that hell — even before a second son overdosed on heroin, the very next night.

Maine is at the burning core of a nationwide heroin epidemic, the perverse outcome of a well-intentioned drive to save Americans from the last drug craze, a widespread hunger for heroin’s chemical cousin, prescription opiate pills such as OxyContin.

Heroin — now cheap, plentiful and more potent than ever — is killing people at record rates. Across the nation, deaths from heroin overdoses nearly quadrupled in the decade ending in 2013, according to a new analysis by the Centers for Disease Control and Prevention.

In Maine, deaths from heroin overdoses ballooned from seven in 2010 to 57 last year. Two-thirds of the victims were, like David, adults in their 20s and 30s. In 2012, heroin accounted for 8 percent of the caseload for Maine’s Drug Crimes Task Force; last year, it jumped to 32 percent. In Portland, the number of addicts served by the needle exchange nearly doubled in just two years. Today in Maine, a single tablet of OxyContin often costs $50; addicts can find a single-dose packet of heroin for as little as $10.

David and his friends, like their parents, always thought of heroin as an inner-city scourge, something for strung-out, dead-end junkies. An entirely different trajectory had been set for them.

The day before David’s funeral, one of his high school friends, a woman with whom he had a romantic relationship that lasted more than a year, wrote about him on Facebook: “I think I lost the moon while I was counting the stars. … we ALWAYS found our [way] back to each other . … I will always love u and cherish what we had my first love. David McCarthy may angels lead u in.”

The woman who wrote that tribute was one of two high school friends who supplied David with heroin, according to McCarthy’s parents, friends and the police.

“We call her the angel of death,” Tolan said. These were kids he had watched grow up. The chief says he believes David’s old friend sold drugs to at least three of the town’s four overdose victims in the past year.

The woman was the love of David’s life in high school, said his mother, Anne Ireland.

“He wanted a girlfriend so desperately,” she said. “I hardly knew her; he didn’t bring her home. He’d decided I was the enemy.”

Two law enforcement officials said the woman and another high school friend, a man who also grew up in Falmouth, supplied heroin to their old friends in Falmouth and Portland. The man sold the fatal heroin to David and, the next night, to his stepbrother, the officials said.

The woman, who is not identified here because she has not been charged with a crime, was anguished by David’s death.

“I’ve been here in my bed since last Saturday,” she wrote a week after the overdose. “It’s safe here and I can cry as much as I want and re-read letters” from David.

The woman has lived in a succession of subsidized apartments; there’s no sign of big profits from her drug sales. Police and prosecutors say that’s not unusual: The heroin trade bears little resemblance to the streetcorner traffic associated with crack or PCP.

In Falmouth and Portland, heroin is often sold by addicts operating out of their own homes. They drive south on Interstate 95 to depressed cities in Massachusetts, to Lowell, Lynn or Lawrence, where they connect with Dominican and Mexican gang members selling cheap heroin from Mexico, now the source of most heroin in the United States.

The dealers from Maine bring back just enough to sell to friends, using their narrow profit to satisfy their own cravings. Sometimes, gang members from Boston, New York or Pennsylvania drive north to Maine and set up in an addict’s apartment, selling for a day or two until the package is gone, paying their hosts with free or discounted heroin.

Then, a few days later, they get on the road and do it all over again.

Starting in high school, David and his friends would do Oxys in the car. Grind up the pill, snort it, go back to the house, smoke pot, watch TV. Repeat.

Two years after David finished high school, his stepmother opened a drawer in the room he shared with Michael and found piles of little packets. The boys told her it was cocaine. She learned years later that it was heroin.

The switch to heroin happened because their regular Oxy supplier had run short.

“It wasn’t even a 20-minute conversation,” said a friend who was with David that day. “It was really just that we couldn’t get what we usually got, and we knew it was clinically basically the same drug.”

After a decade of widespread overprescription of opiates such as OxyContin, Percocet and Vicodin, the federal government pressed pharmaceutical makers to reformulate pills to make them difficult to snort, and it required physicians to prescribe fewer of the habit-forming pills. After OxyContin was reformulated in 2010, street availability of the pills tightened; prices shot up.

“There can be no argument: Heroin has become much cheaper in the past two years because the crackdown on Oxys made it much harder to get pills on the street,” said Dan Perry, the assistant U.S. attorney in Maine who is in charge of drug cases.

“It’s like a metastatic cultural cancer — we went from virtually no intravenous drug use three years ago to now rationing care in a raging, untreated epidemic,” said Mark Publicker, a physician who ran the Mercy Recovery Center, Maine’s largest outpatient drug detox program, until it shut down last month because neither private nor government insurance would pay enough to cover its costs.

Four years ago, hooked and broke from spending his restaurant salary on drugs, David called his mother and told her he had no place to live. He and his old high school girlfriend had broken up. Would Ireland take him in? Mother and son hadn’t lived together for nearly a decade. She brought him home.

“It was so painful to see him, not because of drugs, but because he was so directionless,” said Ireland, a small redhead with a New Yorker’s metabolism. “I didn’t know what to talk to David about. He was into rap and didn’t read a lot of books. The TV was always on BET. I knew nothing about his life, really. I just worried about him, constantly.”

David wore his hoodie up when he was around his mother. He looked gaunt, worn.

“He was this spectral presence,” she said.

She took his salary and put him on an allowance. She thought he had been spending his money on pot. He stole from her, nearly $1,000 that she had hidden where she kept her best jewelry.

One day, she came downstairs to find a jar of yellow liquid on the kitchen counter. “He had pissed in a jar,” she said. “He just lost all sense of decorum, appropriateness. He didn’t care.”

She told him he could not live with her anymore. He sent her an angry email laced with curse words.

Last year, about six months before David died, he called his friend John: He had shot up and later awakened to find that an entire side of his body had gone numb. John arranged for David to be taken to a hospital, where he was told he had suffered a minor stroke.

Kevin had it out with his son. “I’m done — you lied to me, you’ve taken advantage of everything we’ve tried to do for you,” the father told his boy. And he cut him off — no more money, no more living in the family’s ski place.

John had long urged David to get help.

“He’s going to die,” John told David’s friends. “I was saying it, but I wasn’t doing anything about it.”

David thought he could get off the drug by himself. He told friends that heroin wasn’t fun anymore and that he wanted to quit. He had been through detox programs and short-term rehab, but they hadn’t worked. He had too much pride to ask his parents for the $30,000 he would need for a long-term rehab stay. Somehow, his father said, David managed “to put together six or seven months of sobriety, doing it on his own.”

By last summer, his parents said, David seemed to have found his way forward. He looked better, clean-shaven. He was running 6 miles a day.

“He finally seemed like a man,” Ireland said. “So alert, so in the world. And then he decided not to be.”

The night after David died, Michael slept in that same bed. In the morning, his mother knocked on the door, seeking help planning David’s funeral. No answer.

She stepped inside and saw her son lying rigid, his arms above his head. His breathing was labored, raspy. She screamed.

Kevin called 911, again. A physician who was training ambulance personnel nearby responded and administered Narcan, which reverses the effects of an overdose. Portland’s public health department offers addicts free Narcan kits, but the city is not permitted to use federal or state money for Narcan; its supply is privately donated.

Police found a heroin packet in Michael’s room. He spent the rest of the day in intensive care, his survival in doubt. The family camped out in the hospital, making calls about David’s funeral while they awaited word of Michael’s fate.

On the morning after David died, Michael had asked a friend, “Wouldn’t it just be easier to die young and not have to see your loved ones die?”

That night, Michael had called his old high school friend and dealer, the same man David had been to see two nights earlier.

“Do you really want that stuff?” the dealer asked. “It’s the same stuff that killed David.”

The stuff was heroin cut with fentanyl, an opiate that in its legal, prescription form is used to treat post-surgery pain.

“People think they’re using heroin, and it turns out to be fentanyl,” said Jamie Guerrette, the assistant attorney general in Maine who runs the state’s drug task force. “We’re making seizures where users and even sellers believe it’s heroin, and it’s actually a mix that’s potentially 30 to 50 times more potent.”

Fentanyl was found in 11 of Maine’s 57 heroin overdose deaths last year, according to Marcella Sorg, an epidemiologist who is a consultant to the state on drug issues. In its powdery, synthetic, illegal form, fentanyl has been showing up in overdoses around the country.

When addicts unwittingly ingest heroin laced with fentanyl, they consume a vastly more intense dose than they had anticipated. Heroin used to reach Maine in single-dose “tickets”; now, the drug primarily arrives in “fingers,” 10-gram plastic-wrapped cylinders that are “cut,” or diluted, locally.

Michael didn’t believe the heroin would hurt him because he never shot up; he thought snorting was somehow safer. He used it that night, by himself.

Three days after Michael got out of the hospital — one day after David’s funeral — Kevin and Nancy, two other relatives, and four of Michael’s friends surrounded him and read letters they had written. Within a minute, Michael agreed to be taken to rehab. Danzig, the counselor, took the bag they had packed and flew Michael to a Florida trauma center. He stayed in rehab for two months. At the end of the program, he asked to stay another month.

The intervention cost $5,000; the treatment, $25,000. Insurance covered none of it.

Six months later, so far, so good, his family says.

“I realize I’m grasping at straws,” Kevin said, “but we like to think David saved Michael’s life.”

David’s parents decided they had to tell it straight. They owed him that. They wrote his obituary, published in the local papers: “David Paul McCarthy, 29, died of a drug overdose on Friday, Oct. 17, 2014, losing a long-fought battle with drug addiction — a challenge faced by many families today.”

The dealers in the McCarthy case have not been arrested; investigations are ongoing. Prosecutors and police say they are not eager to imprison addicts who sell drugs — they would rather get those people into treatment and enlist their help in going after dealers who bring heroin into the state.

“If you work overdose deaths, then you’re not working the organization above that,” said Perry, the prosecutor. “Overdose deaths are a priority because of the magnitude, the impact of a death, and because they’ll lead us to the groups that are causing the devastation.

“This is not something we’re going to arrest our way out of. We need families to get the problem out of the shadows.”

On a glorious fall day, 400 people packed the Episcopal Church of St. Mary. A hundred more stood outside, although the service was not broadcast outside the building. They were people the McCarthys hadn’t expected to come. They were, David’s mother said, “people with secrets, secrets like ours.”

“The WASP-y Yankees of Falmouth, generations of blond, blue-eyed social x-rays, they all came,” Ireland recalled. “These are the people I thought were so snooty. I mean, after we got divorced, I overheard a woman say they didn’t want their daughter to go with David because we were divorced. But those same kind of people, after he died, came to my door with soup and just hugged me and said, ‘You were a good mother.’

“It was a huge outpouring of love and sympathy and people saying, ‘It was so brave and good of you to put that in the paper.’ ‘We’re so glad you called it what it is.’ ”