Dozens of migrant men have been living in a cramped basement under a Queens furniture store — where beds are so in-demand that only half the inhabitants can sleep there at one time, city officials said Tuesday.

Fire prevention inspectors discovered the illegal boarding house Monday night when they were called to 132-02 Liberty Avenue in South Richmond Hill to investigate reports of a large collection of e-bike batteries, according to the FDNY.

That’s when they found 40 migrants, mostly from Senegal, sleeping in the basement and on the first floor — and realized the true number was actually twice that.

“A further probe revealed that up to 80 individuals have been living there, taking turns to sleep due to the limited space available,” fire officials said, adding that it issued a vacate order for the building.

Inspectors from the city Department of Buildings found that the commercial space and the cellar had been illegally converted into a makeshift hostel, replete with 14 bunk beds on the first-floor and 13 regular beds packed in the basement, officials said.

The cellar also had no ventilation, no natural light, illegal plumbing and too few exits for the amount of people sleeping there, inspectors said.

The buildings department issued a full vacate order for the basement and first floor due to “severe overcrowding and hazardous fire trap conditions,” officials said.

Ebou Sarr, the 47-year-old owner of the furniture business, admitted that he charged each man a $300 monthly “contribution” to live in his little hostel — but said it was a donation, and he never took more than the migrants could afford.

The money, he said, would eventually help “get a building so they can all come and leave the shelter.”

“They don’t even have relatives here, nowhere to go, sleeping on the trains and the streets,” Sarr told The Post on Tuesday. “So we have to intervene.”

Sarr, who is from Senegal himself, said he started the pet project when his cousin arrived from the country in October.

His friend’s brother came the following month, he said, and then more showed up — some from Senegal, others from West African countries like Mauritania or Gambia.

Sarr said he was trying to teach some of the men to sell furniture, and splitting the profits when they brought in a sale.

“I am helping the guys,” Sarr said. “I’m giving them somewhere to stay. Some of the guys who heard about me, they weren’t even going to the shelter. They were coming straight to me.”

The men slept two to a bed, Sarr said. And after the basement filled up, he set up a dozen or so queen-sized bunk beds on the main level that could sleep another four men each.

The housing was necessary, he said, because of the 30-day limit on single adult migrants in city shelters, after which they have to reapply for entry.

“Here you don’t have problems,” said Malick Ndiaye, 31, who came to the US from Senegal nearly a year ago and had been staying at Sarr’s boarding house for two months. 

“In the shelter, every month you have to go back to Manhattan…and they send you to another place.  This takes time – 10 days, 20 days,” he told The Post.

“Sometimes you don’t take shower every day,” he said, adding the food at Sarr’s was better than what the city hands out.

After the sudden visit from inspectors, Ndiaye said he was forced to sleep on the subway and that some of the others were left outside in the cold.

“It’s very difficult. I don’t know why they didn’t give us date, like one week, 10 days,” he said. “They come yesterday in the morning and in the night .. we are out.

While Sarr admitted he hadn’t gotten permission to set up his bunk house, he also said he he didn’t even know he needed it — and that figuring out the fire codes would have taken too long, anyway.

“Oh my God, I could not wait for that,” he said. “I cannot even think about the rules, with all the people that were sleeping outside in the streets. We have to help them! We cannot leave our people outside in the streets sleeping like animals.”

He also brushed off concerns that packing so many into so small a space was a fire hazard.

The basement had two exits, the migrants didn’t cook inside and they left e-bikes and their combustible batteries outside, he said.

“I understand that, they say it’s not safe,” Sarr said. “But you know, I didn’t see any danger.  We don’t want danger. We were being mindful … We are smart people. We’re not dumb. So fire hazard? What fire hazard?”

The city disagreed heartily.

Inspectors hit the building’s owner — 132-02 Liberty Avenue Management Corporation — with two violations: One for illegal work without a permit, the other for occupying the building contrary to city records, officials added.

Each carries a potential penalty of up to $25,000 — although the more standard amount levied is about $2,500.

Maria Torres-Springer, the city’s deputy mayor for housing, economic development and workforce, said the shocking find was emblematic of the larger migrant and housing crises weighing down the Big Apple.

“It is not a new thing that too many people make desperate choices about where to live and what to pay for and at the root of that is that we haven’t built enough housing,” she said during a press briefing.

Mayor Eric Adams said he’d been told about the illegal dwelling just after midnight, and that he didn’t know where city officials brought the migrants after vacating the makeshift motel.

“When you have situations like what we’re facing here, there’s some people that are going to attempt to exploit it, some who are going to attempt to do illegal housing,” he said.

“We don’t have an exact location to give to you,” he added. “I know they are not in that basement any longer or inside the store.”

Sarr, meanwhile, said he has previously tried reaching out to the mayor’s office for help but wasn’t successful.

“I was helping, and that is the intention,” he told The Post.

“We’re going to keep doing what we’re doing to get a better place,” he said. “We have some amount of money that we can use to get a building … We’re trying to work with the city.” 

Additional reporting by Aneeta Bhole