Two days before last Christmas, Beth Stephens was full of plans and promise. The brilliant, 39-year-old scientist who had studied in Paris, completed a Ph.D. in microbiology and had worked as a researcher for the federal government seemed to be getting her life back together.

The slim, fun-loving brunette who enjoyed outdoor concerts, afternoon chats over strong coffee with friends and showing off her soccer moves to her 9-year-old nephew, Lincoln, was determined to move out of a dark place.

“I’m out of the shelter now. Plan to put in a few online job apps and follow up w another,” wrote Stephens in a series of texts to a friend, studded with exclamation points, happy faces, and chatter about plans for Christmas Eve.

Hours after she sent that text, she lay dying in the lobby of a garbage-strewn Bronx housing complex. Police answering a 911 call rushed her to nearby Lincoln Hospital, where she was pronounced dead on arrival.

The cause of death was an accidental overdose of fentanyl, a synthetic opioid 100 times more powerful than morphine.

Fentanyl, produced by Mexican drug cartels with chemicals imported from China, has become the fastest growing cause of overdose deaths in the country and was behind nearly half the city’s 1,374 overdoses last year — a historic high. It gained worldwide notoriety last year after Prince died of an accidental fentanyl overdose in his Minnesota estate.

But Beth Stephens was not a famous rock star. And she had no family in the city. It took three weeks for word to reach her loved ones that she was dead and her body was in the morgue. The beautiful scholar had become a statistic — another lonely and anonymous victim of the scourge of opioids.

“She was so kind and loving,” sobbed Beth’s mother when contacted by The Post at her home in Texas. “She was supposed to come back and live with me. I’m telling her story because I don’t want this to happen to anyone else.”

Elizabeth Ann Stephens was born on July 21, 1977, in Clarksburg, W. Va., the first child of Elizabeth and Gary Stephens. Her parents called her Beth so she wouldn’t be confused with her mother.

Beth’s father had three degrees, including one in mathematics. At one point he worked for the IRS, and as a counselor and teacher at a nearby college.

From an early age, it was clear that Beth had inherited her father’s gift for numbers, and before she started kindergarten, her mother said she could already add, subtract and do long division.

“I would want to quit doing math with her, and she would beg me, ‘Just a little more, ma,’” Elizabeth Bruffy told The Post.

But home life was difficult, marked by poverty and abuse. Shortly after the births of Beth’s younger sisters, Kari Lynn and Jannah, Beth’s mother left her husband.

The bitter divorce branded Beth for life, Bruffy said. Gary Stephens, whose family was well-connected in their West Virginia community, convinced a local judge to give him full custody of the three girls. Beth was 9 years old.

“It was horrible for all of us,” said Bruffy, 67. “The girls didn’t want to go and live with him.”

The father, who suffered from severe depression, neglected the three girls, according to the family, and Beth took on the role of surrogate parent. “She was taking care of us a lot,” said Jannah Alaoui, the youngest sister. “She got us up for school and got us our breakfast ­every day.”

Seven years later, Gary Stephens returned the girls to their mother, who was then working as a manager of an apartment complex in nearby Morgantown, W. Va.

“We grew up on welfare in a pretty poor hillbilly town,” said Alaoui. “Our childhood was full of drama and constant setback.”

And life with their mother and her new boyfriend also proved tough. The boyfriend, who died five years ago while serving a life term in prison for murder, was abusive.

“I saw him beating the s–t out of my mom,” Kari Lynn Marra told The Post. “He pulled my arm out of place twice when I was 5 years old.”

Beth was in her senior year of high school when the girls moved back in with their mother. The trauma of the divorce still weighed on her, and she had begun drinking in middle school, hiding bottles of vodka in a hole in her bedroom wall, said Bruffy.

Still, Beth fought hard against the hand she was dealt and became a rising star at Morgantown HS — a diligent student who played on the volleyball team and practiced ­jiu-jitsu.

During her senior year, Beth was only required to attend half a day of classes, and would spend the rest of the day doing scientific experiments at a lab at the University of West Virginia.

“I would pick her up at high school with a hot plate of food, and she would eat during the 10 minutes that it took me to drive her to her work at the university,” said Bruffy.

After graduating high school, Beth enrolled at the University of Alaska. She earned her bachelor’s degree in 1999, and went on to graduate school at the University of Massachusetts.

“Beth is the reason I went to college,” Marra, 38, told The Post. “I dropped out of high school because of all the problems we had, and Beth invited me to live with her when she was at UMass. She changed my life.”

Beth did the same for Jannah, who at 19 was a single mom with few prospects.

‘He pulled my arm out of place twice when I was 5 years old.’

- Kari Lynn Marra

“She invited me to come live with her,” said Alaoui, now 36 and a nurse/midwife living in Texas.

“I remember when I applied to grad school in California, I needed a computer but I couldn’t afford it,” Alaoui told The Post. “Beth just shipped me a brand new laptop. I don’t know where she got the money, but it makes me cry just thinking about it.”

Despite continuing problems with alcoholism, Beth completed a masters degree and moved to Paris in 2003 to continue graduate studies at the Sorbonne.

“She flew me out there and we went to the Eiffel Tower, to different churches and wonderful bakeries,” Bruffy told The Post.

After Paris, Beth returned to the University of Massachusetts where her family said she completed her P.h.D., and began working for the US Fish and Wildlife Service, testing soil samples. She had a live-in girlfriend and her life seemed to be going in the right direction, her family said.

“When she was sober, she was such a beautiful person,” recalled Marra.

But in 2007, Beth’s life changed forever.

Her family says she was involved in a car accident, and suffered serious injuries to her back. She spent a month in a New England hospital, where she was prescribed morphine for her excruciating pain, Alaoui said.

And she continued to take morphine for a year after she was discharged.

“I said, ‘Beth, that can’t be good for you,’ ” said Alaoui.

When she couldn’t obtain morphine, Beth began buying heroin, and was arrested a few times for possession of drug paraphernalia, a misdemeanor, public records show.

As Beth’s life continued to fall apart, she signed up for Alcoholics Anonymous and fell in love with a fellow addict. She had already broken up with her previous girlfriend.

Beth married Sherry, a teacher for special-needs children, in 2008, in a ceremony officiated by Marra, who became a Unitarian Universalist minister for the occasion.

But the marriage was fleeting. According to Marra, Sherry couldn’t live with her spouse after Beth slipped back into heavy drinking and drug use.

After the split, Beth moved to New York, where she had often visited, flopping on friends’ couches and exploring the city.

“She always said she loved New York,” said Bruffy. “She loved the freedom of the city. She felt she could be herself there.”

On her Facebook page, Beth regularly posted pictures of a snowy Central Park and the Manhattan skyline. There are also selfies of the pretty young woman posing with blond, pixie-cut hair and green eyebrows. She meant to dye her hair blue, but ended up with the green eyebrows and blond hair, according to a post on her Facebook page.

“She was really beautiful, and she loved to dye her hair, and would show up with different colors,” recalled her friend James, who declined to give his last name.

He said he met Beth in The Bronx a year before she died. “But she got wrapped up in something bad and before you knew it she was dead.”

Although her family has few details of her daily life in New York, friends in the city said she drifted between a women’s shelter in the South Bronx and the couch of a friend living in a Mott Haven housing project.

‘She was trying to stay alive. But it was too late.’

- Elizabeth Bruffy

A man who identified himself as Mark and said he worked as an electrician for the MTA told The Post he met Beth at a Bronx Burger King three years ago. They became friends, and met over sodas at fast-food restaurants and occasionally went to house parties, although it was difficult for them to meet at night because Beth had to honor a 10 p.m. curfew at the shelter if she wanted a bed for the night.

In texts Mark shared with The Post, Beth asks to borrow small amounts of money, and constantly complains about being cold at the Bronx shelter where she would spend a few nights every week.

“I have a question about whether you can meet me and help me with a little cash,” she wrote in a text from October 2016. “I’m again broke . . . And being out there with not a dollar for a tea or something is really bad.”

In another text to Mark, Beth wrote, “I am focused most days on getting something to eat. Cold now. But I will survive and pull from my strength that has allowed me to succeed in positive things.”

Beth’s addiction made it impossible for her to hold on to a job for any length of time, but she did volunteer at a Bronx drug-treatment facility, her family said.

At BOOM Health, where Beth worked a few days a week dispensing clean syringes and speaking to fellow addicts, she sprang into action last year when she saw an addict going into distress. Beth proudly related to her mother how she took hold of a syringe and a vial of Narcan, an opioid antidote, and administered it to the addict, saving his life. Mark told The Post that Beth always had two doses of Narcan in her purse in case of an overdose.

“Beth had such a good heart,” Bruffy told The Post. “I was really proud of her when she told me that story and I could tell she was very proud of herself.”

About a month before she died, Beth herself suffered a heroin overdose and was briefly admitted to Lincoln Hospital, her family told The Post.

After the near-fatal overdose, Bruffy convinced her daughter to live with her in Texas until she could get back on her feet.

“Beth mowed my grass, put in mulch and cooked things,” said Bruffy. “We watched every episode of ‘Downton Abbey’ together on the couch and went shopping. We even bought matching watches.”

After spending a few weeks with her mother just before Thanksgiving 2016, Beth went back to New York, promising she would return to Texas and that she would text her mother once a day while she was in the city.

Elizabeth Stephens

On Dec. 23, Bruffy didn’t hear from her daughter. When Beth didn’t contact her mother and sisters at Christmas, the family knew something was wrong. They contacted Lincoln Hospital where she had been admitted the previous month and tried to enlist the NYPD to search for Beth.

The hospital claimed that Beth had been treated and released on Dec. 23, and the police refused to fill out a missing-persons report because the family is from out of state, Bruffy said.

“We never gave up hope,” said Bruffy, adding that Beth had her family’s phone numbers on her phone and at least two pieces of identification when she was taken to the hospital. “We kept thinking she was alive because no one could tell us what had happened to her.”

On Jan. 12, after repeated calls to the hospital, Alaoui reached the physician who had tried to revive Beth when she was rushed into the emergency room two days before Christmas. But the doctor refused to tell the family what had taken place, and gave them another phone number to call.

“I kept asking if my sister was alive or dead,” said Alaoui. “But the doctor wouldn’t answer and just gave me a number without any ­explanation. She said, ‘Just call this number.’ ”

The number was for the morgue, where officials had identified Beth through fingerprints and a tattoo.

Two weeks ago, Bruffy filed suit against Lincoln Hospital and the city, citing “negligence [and] recklessness” in failing to notify the family of Beth’s death.

A spokesman for NYC Health + Hospitals, which oversees Lincoln Hospital, said patient-confidentiality laws prevented him from commenting, and a spokeswoman for the city Law Department said the agency is reviewing the case.

The family, which had assumed that Beth had died of a heroin overdose, was surprised when they ­finally read the medical examiner’s report.

According to the ME, there was no trace of heroin in her system. The cause of death was “accidental fentanyl intoxication,” said Mark Fox, the family’s attorney.

And there was another surprise.

On the floor of the lobby of the Bronx housing complex where Beth lay dying, police found a syringe and a vial of the opioid antidote Narcan.

“She knew what was happening, and she was trying to save herself,” said Bruffy. “She was trying to stay alive. But it was too late.”