A postpartum-depressed Brooklyn mom was moments away from killing herself and her 6-month-old baby — but a gun shop owner in the Poconos and a quick-thinking NYPD cop worked together to save her.

The 27-year-old mom — who lives in Pennsylvania but had been staying with family in Brooklyn — took her 6-month-old daughter out of a nearby daycare early on Friday and started sending disturbing text messages to her own mother, Latika Thorpe, and to her sister.

The woman, whose name is being withheld, said she “Can’t go on like this any more,” and planned to kill herself and her baby, police said of the text messages.

The desperate family members called the NYPD for help, explaining the new mom had been depressed after the birth of her daughter, wasn’t answering her phone and might be headed to home to Pennsylvania to kill herself and the baby, police said.

Officer Michelle Schack and her partner Officer Gulrej Nandha rushed to the family’s Canarsie home.

“Time was of the essence,” Schack told reporters, recounting the savvy — and lucky — police work that would save both mother and baby.

“We gotta stop this woman somehow and she has a baby and herself to think about,” Schack said of her thinking as Thorpe relayed her concerns.

“We were able to use our department cell phones to track the vehicle and we saw it was going over the Verrazano Bridge,” Schack recounted.

Then Thorpe told her that was the route to the family’s Pennsylvania home.

Schack made a mental list of options. She could trigger an Amber Alert with the New York State Police, and beyond that, hope someone would find them.

But then Thorpe mentioned how easy it is to get a gun in Pennsylvania — and that’s when it all clicked for Schack.

“That’s when I just started quick thinking, ‘Let’s call gun shops. That’s most likely where she was heading to,” Schack explained.

She asked Thorpe if there were any on the way to the family’s Poconos home. Thorpe wasn’t sure. But it turns out there was.

Schack randomly found Pocono Mountain Firearms in Scotrun on Google and called the owner on a whim. She gave the owner a description of the mom and baby in hopes they’d come in. And in hopes that local cops would be able to then stop the mom before she left the shop with a gun.

“Within two minutes he called back and said ‘They’re here’,” Schack recounted of the shop owner.

“I said you have to stall them.”

The owner of the store, Michael Conforti, 50, told The Post that when the NYPD first called him, he wondered if it was a prank.

But then he hung up, and a woman matching the description the NYPD gave, and driving the car the NYPD had described, suddenly showed up.

“That’s when the red flags started popping up,” Conforti explained.

One of the shopkeepers started talking to the woman, who was noticeably “aloof” when it came to the baby and looked “very sad”, Conforti said.

They asked her if they could help her and she said: “Yes, I’d like to buy a gun.”

By that point, Conforti realized even if it was a prank, he’d rather err on the side of caution.

He called 911 as the NYPD had instructed him and tried to stall the woman as she filled out the paperwork to purchase a “small handgun.”

Soon enough, the Pocono Mountain Regional Police arrived and brought the mom and the baby to a local hospital for evaluation.

If it wasn’t for Schack’s quick thinking, and the help of the out-of-state gun shop owner, things might not have turned out so well.

“I was hoping the police were gonna get there quickly and everyone was gonna be safe. The second I heard [she was there] it was amazing,” Schack said.

“The grandma thanked me, the sister thanked me, they said you two went over and beyond. Most cops wouldn’t have done this. This was amazing what you did.”