OAKLAND, Calif. — The first complaint came in 2014. Piles of trash were reported next to the building. Later that year, construction materials blocking the sidewalk drew another complaint. Last month, another was lodged, leading to an investigation of illegal construction inside.

The warehouse that was engulfed in flames on Friday night, leaving at least 36 people dead, was well known to people who spent time there for being filled with illegal residences and potentially hazardous construction. Known as the Ghost Ship, it had become an artists’ colony, a refuge from the Bay Area’s rocketing rents, and a space for performances like the concert that was underway when the fire erupted.

The tragedy prompted questions about what officials should have done to shut down the motley tenement. It also brought attention to the boom in illegal housing across the region, where many people have resorted to makeshift living arrangements because they have been priced out of the regular market. The questions were many: How did the fire start? Was it accidental or deliberate? Will anyone be punished for the carnage?

The building did not have a permit for residences, or one for performances. Its landlord had a history of owning properties with building violations. People who had lived in the warehouse or visited described a place rife with fire hazards — a boarded-up upstairs exit, a cobbled-together stairway made partly of wooden pallets, propane tanks used to heat water, and piles of flammable debris.

“It was a complete maze — I mean, there was really no clearly marked exits,” said Ben Phelps-Rohrs, who told the public radio station KCRW he stepped outside the concert just before the fire broke out. “It was a place where you could lose yourself.”

Inspectors from Oakland’s Planning and Building Department had opened an investigation into illegal construction after the third complaint, but many said the city did not do enough to respond.

“The community complained about debris; we react to it, we go and we clean it up,” said Jose Ortiz, a neighborhood activist. “It’s really ridiculous that we have to end up with a tragedy like this for the city officials to react to it.”

Video

More than 35 people were killed on Friday night in a warehouse fire in Oakland, Calif. The authorities expect the death toll to rise.CreditCreditMarcio Jose Sanchez/Associated Press

At a news briefing on Monday afternoon, Mayor Libby Schaaf said the city would do “everything we can to ensure that you will get, that the families will get, that this city will get the answers to every question about this incident.”

The Alameda County district attorney, Nancy O’Malley, said that her office had begun a criminal investigation but that it was too soon to speculate about potential charges. Investigators are looking into whether anyone should be held criminally liable for the fire, she said. When pressed, she said charges could range from murder to involuntary manslaughter.

The buildings department said it sent an inspector to the warehouse on Nov. 17, three days after the illegal construction complaint, but the inspector was unable to gain entry. A fire department official said that without knowing the building was being used for housing or concerts, the department would have inspected only once every two years, and that on its most recent visit, it, too, was unable to enter.

But some residents of the building questioned the idea that anyone had tried to inspect it. “We would have known if somebody from the city had come by to advise us about hazards,” said Carmen Brito, who escaped the blaze.

“That place was a tinderbox,” said Danielle Boudreaux, who had visited many times. “And anybody who went in there who had any kind of authority should have not allowed it to continue.”

Before the fire thrust Oakland into the national spotlight, officials here had other preoccupations. The city, the most crime-ridden in California, has had six police chiefs in seven years, and remains without a permanent one after a scandal involving officers having sex with a young prostitute rocked the city government this summer.

Code violations were not at the forefront of the officials’ concerns.

Oakland officials said the city takes illegal housing seriously, but there are so many informally converted spaces that building inspectors, firefighters and the police are overwhelmed by the problem. California law says that an inspector cannot enter unless admitted by an owner or resident, and officials say that people often refuse to let inspectors in, fearing eviction.

Fruitvale, the neighborhood where the Ghost Ship was located, is a dense grid of old industrial structures, houses and apartment buildings, populated mostly by Latino immigrants. It is well trafficked both by commuters headed to other parts of the Bay Area and by prostitutes who stand along the sidewalks of International Boulevard.

The Ghost Ship was run by a married couple, Derick Ion Almena — also known as Derick Ion — and Micah Allison, whom residents described as the master tenants who rented the building and sublet parts of it to others. The building was owned by Chor Nar Siu Ng, who lives elsewhere in Oakland. It is unclear what Ms. Ng, who could not be reached for comment, knew about conditions inside.

Current and former tenants said that when Ms. Ng or her daughter came by, Mr. Almena and Ms. Allison told tenants to pack away bedding and cooking supplies. Justin Manchester, who lived in the building for six weeks in 2014, said that the master tenants told other residents to hide in a nearby Wendy’s restaurant when Ms. Ng visited.

“They would usually prepare for days,” he said, and they would tell tenants to “make your space look like nobody had been staying there.”

Mr. Manchester, 25, who now lives in Texas, said that he moved to the Ghost Ship after being evicted from another warehouse known as Sugar Mountain, and that he knew of at least seven warehouses in Oakland, all creatively named, where artists lived under similar conditions, paying below-market rents.

Ms. Allison, who on her Facebook page calls herself the Mother Superior of the Ghost Ship, and Mr. Almena, whose page has been taken down, did not respond to messages seeking comment. When a local television station, KGO, found them Sunday night at a hotel, Mr. Almena said of the fire victims: “They’re my children. They’re my friends. They’re my family. They’re my loves. They’re my future. What else do I have to say?”

The Alameda County authorities took the couple’s three children from them last year, after reports of neglect and unsafe conditions, according to Ms. Allison’s father and a county official. The couple regained custody of the children, now ages 6, 7 and 13, several months later. The Alameda County Social Services agency said it could not comment, so it was unclear whether an inspection of the family’s living arrangements was conducted.

Mr. Almena pleaded no contest in January to a misdemeanor charge of receiving stolen property, an Airstream trailer, and was sentenced to three years probation. Some residents described having run-ins with him and accused him of cutting off the electricity of tenants he didn’t like.

Ms. Ng, who owns the building and the adjacent lot, bought the property in 1988. County records show that she and her family have owned several properties in Oakland, with a history of building violations that have caused the city to place liens against them.

These include at least $1,000 for failure to fix unsafe conditions at a property on Eighth Street, and at least $3,000 for failure to fix conditions at a property on International Boulevard.

And in 2007, the city issued liens for at least $6,800 for her failure to address unspecified conditions at 1305 31st Avenue, the property that would become the Ghost Ship. The liens on the building were paid off by 2014.

Oakland has seen rents and home prices skyrocket with the local technology boom. Rents are up about 70 percent from five years ago — the fastest increase in the nation according to Zillow, the online real estate pricing service. The $2,899 median price is now just shy of cities like San Francisco and Manhattan.

In Oakland, artists and musicians have long been using industrial warehouses as a cheap way to find a place to live and work in the same space.

The paradox is that illegal housing is cheap partly because it is illegal, said Thomas Dolan, an Oakland architect who helps building owners convert warehouses.

“You’ve got a market economy, a gentrifying real estate market and people feeling that they need to go underground,” he said.

Julie Turkewitz, Thomas Fuller and Conor Dougherty reported from Oakland, and Richard Pérez-Peña from New York. Dai Wakabayashi contributed reporting from Oakland, and Caitlin Dickerson and Niraj Chokshi from New York.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Oakland Site Violated Codes but Filled Need. Order Reprints | Today’s Paper | Subscribe