Police in San Francisco’s Tenderloin reached into their own pockets in the wee hours to help house a mother and her toddler whom they found camping in an alley — after the shelters of last resort that the city relies on to keep families off the streets didn’t open their doors.

“I don’t want to see a 2-year-old sleeping in the Tenderloin — it’s not right,” said Officer Kevin Lyons, one of several cops who paid to put the young girl and her mother in a neighborhood motel.

The story began one day last week at 2:40 a.m. when officers from Tenderloin Station were dispatched to the corner of Larkin and Myrtle Street, a three-block-long alley, to check on a 36-year-old woman and her daughter who were camping and unable to find shelter for the night. The woman, who had food and blankets, told police she was “currently homeless” and had previously stayed in shelters with her daughter, but that she had no family or friends who could help her.

The officers began calling around to try to find space in a family shelter — but none of the five they dialed answered the phone.

They then asked dispatch if an officer at Southern Station on Third Street could check at a nearby women’s shelter — like the others, a nonprofit run under contract with the city. After waiting, the Tenderloin cops were told there were no beds — or even chairs — for the mother and daughter and that the shelter “provided no further assistance.”

The answer was the same when Mission District cops were sent out to check at a drop-in center in their area.

Because it was cold, Fire Department paramedics came out and checked the mother and daughter. But there was no medical emergency, and all the paramedics could do was leave them with some more blankets.

The cops even contacted Child Protective Services, but because it was after hours, they could only leave a message.

Lyons, who was monitoring what was happening over the radio back at Tenderloin Station, couldn’t believe what he was hearing. He began collecting $10 and $20 donations from the cops there. Soon he had $240, enough to get the mother and child a room for a couple of nights at the Civic Center Inn on Ellis Street.

“Every day, the city is touting its homeless program and how many people they are getting off the streets,” said Lyons, an 18-year SFPD veteran. “But if the cops didn’t do anything in this situation (and something bad happened), they would be hung by the flagpole.

“This isn’t the first time (we’ve helped), and we are not looking for accolades. We just want to be able to call these services for help,” Lyons said.

“It’s awesome they did it,” said Jennifer Friedenbach, director of the Coalition on Homelessness activist group. “It’s not the first time cops have covered (such) costs. They’ve let people sleep in the stations, and they passed hats to put people up in hotels.”

But she said the circumstances here underscore the fact that “we do not have a safety net at all.”

Capt. Teresa Ewins of Tenderloin Station followed up with in a email to Sam Dodge, deputy director of the city’s year-old Department of Homelessness and Supportive Housing, looking for answers.

Dodge told us the city does have contracts with a pair of church-run emergency shelters for families, and they “always have a little space.” The police report doesn’t indicate that the officers phoned either shelter, but it probably wouldn’t have done much good.

We found that the nearby First Friendship Family Shelter on Steiner Street doesn’t answer its phones after 5 p.m., and representatives did not return a voice-mail message we left during the day.

Dodge said clients can knock on the doors after hours, but according to Friedenbach, “they frequently will turn away people who show up after the (8 p.m.) curfew.” And despite official counts showing space, she said, both shelters often are full.

“Clearly, it’s a place where we can improve,” Dodge said.

He said he had urged the Tenderloin captain either to call him directly or to call the 24-hour 311 help line if her officers can’t find an available shelter.

This time, he said, the cops who stepped up “found an answer in a tight situation ... and it speaks to their dedication. But we want to make sure they don’t have to invent the wheel if they ever come across this situation again.

“There is support,” Dodge said, “and if they don’t have answers immediately, there are ways to get the answers.”

Ewins said Dodge and other city officials “have been very good at giving us what we need.” Given the complexities of dealing with a large homeless population, she said, challenges are to be expected.

“It’s a group effort, and that’s what our approach is right now,” she said. “Any family is going to want us to go the extra step for their child — that’s part of our job.”

As for mom and her toddler? After their two nights at the Civic Center Inn, they disappeared back onto the Tenderloin’s rough-and-tumble streets — until Sunday night, when police got another call about a woman and child who appeared to be homeless.

It was the same mother and daughter. This time, the cops went straight to First Friendship Family Shelter. When the officers dropped Dodge’s name, Lyons says, the doors opened wide.

“There has got to be a better system,” he said. “Especially with a child involved.”

All this in a city that spent $275 million on homeless services last year.

S an Francisco Chronicle columnists Phillip Matier and Andrew Ross appear Sundays, Mondays and Wednesdays. Matier can be seen on the KPIX TV morning and evening news. He can also be heard on KCBS radio Monday through Friday at 7:50 a.m. and 5:50 p.m. Got a tip? Call (415) 777-8815, or email matierandross@ sfchronicle.com. Twitter: @matierandross