SAN FRANCISCO (MarketWatch) — San Francisco is America’s poster child for unaffordable city living: The median value of homes rocketed from $670,000 in 2012 to $1.13 million this May.

But I bought a brand-new, one-bedroom condo in the heart of the Mid-Market District, right around the corner from Twitter’s headquarters, for just $268,000.

I’m living proof that it’s possible to buy a home in San Francisco even if you’re not a millionaire.

I moved in! (Eventually.) Courtesy Sally French

But while I got mine for about a third of the market’s going rate, my story illustrates just how hard it is for middle-income earners in San Francisco to do the same.

And it shows just how thorny and intractable the issue of affordable housing is for cities across the country today.

The day I discovered ‘BMR’

As a 23-year-old whose income is nowhere near the $147,996 studies say you need to afford a home in San Francisco, I assumed homeownership would be out of my reach for decades — if not forever.

But in early 2015, out of curiosity, I browsed real estate sites, setting the price filter below $300,000. To my bewilderment, a few listings popped up. The descriptions had one thing in common: they were all part of the city’s Inclusionary Housing Below Market Rate Ownership Program.

I quickly did some research. San Francisco requires developers of market-rate homes to fund construction of below-market-rate, or “BMR,” homes. The city then mediates their sale. At the end of 2015, San Francisco had about 3,500 BMR units.

To qualify, you must live or work here, and earn less than 120% of San Francisco’s median income. (In 2016, that means $90,500 for a single-person household, more than twice the national average.)

In theory, more than half of San Franciscans qualify. I was one of them.

That made me eligible for the city-run housing lotteries that are held each time a building opens. I had as good a chance as anyone else.

In practice, though, the question of who qualifies — and who should qualify — is complicated. And so is the question of whether the program actually makes a difference.

A city bleeding its middle class population

San Francisco has been concerned with economic diversity in housing since before the tech boom: Its BMR housing program has operated in some form since 1992.

This isn’t the only city bleeding middle-class residents. The share of adults living in middle-income households — those with incomes between $42,000 and $125,000, depending on household size and location — fell in 88% of U.S. metropolitan areas between 2000 and 2014.

Meanwhile, the share living in upper-income households increased. (They increased in lower-income households too, for reasons including a higher low-income threshold, social programs that help low-income individuals, and increased homelessness.)

Terrence Horan, MarketWatch

American cities are watching what’s happening here warily.

“Seattle and Austin and Portland are afraid of becoming San Francisco,” said affordable housing advocate Shannon Way, director of programs at advocacy group Homeownership SF. “San Francisco is the canary in the coal mine.”

Many city-run housing programs are for low-income earners. But cities are increasingly focused on making homeownership affordable for middle-income earners, too. BMR housing programs like San Francisco’s are in Chicago, Boston, San Diego, Denver, New York City and Washington, D.C., among others.

“A lot of people with middle-income salaries don’t ever think a housing program like this is something they would even qualify for,” said Scott Wiener, a Democrat on the San Francisco’s Board of Supervisors who is running for state senate. “We have to serve working-class people.”

My winning lottery ticket

A few months after I learned about the program, a 165-unit BMR building on Mission Street in the rapidly changing Mid-Market neighborhood began taking applicants.

In July of 2015, after two months gathering a massive binder of paperwork — including three years of tax forms to prove my income, three months of bank statements, and a pile of other application forms — and completing a required course of homeownership classes, I showed up on lottery day in a room packed with more than 300 other would-be homeowners.

Each lottery requires applicants to submit a huge folder of paperwork, including bank statements and three years of tax forms. Sally French / MarketWatch

San Francisco is supposedly a high-tech city, but the lottery was conducted in the most low-tech way possible: A city employee pulled paper tickets out of a shoebox wrapped in glittery paper. In a stroke of luck, mine was the 78th chosen.

I waited three anxious months as the city’s Office of Housing and Community Development worked through the 77 applications ahead of mine. In October, I got a call: I could pick my unit, and would move in in December.

The price of my 615-square foot, one-bedroom, one-bathroom, 10th-floor condo was $268,000, a ridiculous bargain by San Francisco standards.

It’s appraised at $640,000, though listings for nearby one-bedrooms can approach $1 million. Over the course of a year, my mortgage and HOA fees will be some $23,000 less than I’d pay to rent a similar apartment in the same area.

When I leave, the city will dictate the resale price based on the same formula that set my price, and it’ll be sold to another BMR applicant. While I’m building some equity, it’s unlikely that I’ll make a huge profit — and I’m not allowed to rent it out.

In October, I toured my soon-to-be-home. I began planning where I’d put my furniture and, since Christmas was coming, where I would put a tree. I put down a deposit, a first step toward completing my down payment. I signed (many) more papers. I called my mom.

“This is the best Christmas present you will ever give yourself,” she told me.

San Francisco: the canary in a coal mine

The story of how hard it is to buy in San Francisco today is well-told. Micro-apartments that measure less than 250 square feet sell for $425,000; Unlivable teardown shacks can sell for more than $400,000.

Renting here is expensive, too. A study published earlier this year said you’d need to make more than $216,000 to rent a two-bedroom apartment.

Most economists agree it comes down to basic supply and demand.

Nationwide, there’s been a shift toward urban living, creating more demand for homes in the country’s most desirable cities. Between 2000 and 2012, twice as many 25- to 34-year-olds moved within 3 miles of a central business district as to the suburbs, according to City Observatory.

Many are trading space for shorter commutes, convenient commerce, cultural opportunities and public transportation, a change in the way Americans live that suggests an evolving American dream.

“The nation is seeing a massive shift away from the suburban housing we spent the last hundred years building,” said Way.

But San Francisco’s housing crisis can’t be boiled down to just that. A morass of factors makes this city’s issues even more complicated.

The setting is picturesque, but it covers only 46.9 square miles. We’re surrounded by water on three sides. That makes sprawl pretty much impossible.

There are strict zoning requirements. Most of the city has zoning rules preventing buildings taller than 40 feet, which some would like to see lifted.

The areas in yellow represent places in San Francisco where buildings cannot be taller than 40 feet. San Francisco Planning Department

There is the network of advocacy groups working to curtail new development, their arguments ranging from the aesthetic (“It’ll block my view of the water!”) to the political (preventing luxury housing in rapidly gentrifying neighborhoods).

And there’s our tech-driven economic growth. The latest Bay Area tech boom brought a huge increase in jobs, but not enough new housing to accommodate the region’s worker influx.

San Francisco and the Silicon Valley counties of San Mateo and Santa Clara added a combined 385,800 jobs between 2010 and 2015, according to the California Employment Development Department. Building permits for just 58,324 units were issued in those counties over the same period, according to the U.S. Census Bureau. That is enough space to hold just 150,000 new residents, according to The Wall Street Journal.

Peter Cohen, co-director of San Francisco’s Council of Community Housing Organizations, blames city officials for a lack of foresight. It attracted tech companies with thousands of high-earning employees, he said, but not enough new housing units for them.

“Mayors love to create jobs,” he said. “But it wasn’t comprehensive. Their housing strategy never matched their job strategy.”

Mayor Ed Lee, who has held the seat since 2011, has made the largest investment in affordable housing in modern San Francisco history, according to a city spokeswoman. “San Francisco has produced more housing units than any other city in California while successfully guiding San Francisco out of the Great Recession,” she said.

Who does the BMR program serve?

The question of whether San Francisco’s BMR program is accomplishing its goal of putting people from lower- and middle-income households into homes is up for debate. And it’s complicated.

The supply is limited. The number of BMR homes the city awards each year is driven by its overall rate of development: Market- rate developers must set aside a certain number of units for the BMR program, so more luxury condos theoretically mean more middle-income units.

Terrence Horan, MarketWatch

A variety of factors shape demand. More than 60% of San Francisco households have salaries low enough to qualify, according to city data, but not all of them can actually afford the units.

You need to be able to put at least 5% down — the city offers interest-free loans for the remainder of the 20% down payment — and make monthly mortgage payments, which vary based on your interest rate.

Most houses are generally priced at a level deemed affordable for people making between $60,300 and $90,500, which narrows the pool down to 16% of the population (though there are some units in the BMR program that target lower incomes than that).

Terrence Horan, MarketWatch

There is no required minimum salary, but while someone making below $60,300 might qualify they often can’t afford the mortgage payments on most of the units. (Some work around this with larger down payments.)

About half of all applicants are disqualified for reasons including bad credit, which stops them from getting loans, or too much past income. If you make even a dollar over the maximum salary allowed, you’re out. Other rules weed out people who might be unemployed but are cash-rich.

Would-be buyers are closely watched. Shortly before Christmas, the city contacted me about deposits to my bank account — primarily $200 chunks from Venmo, made as my roommates repaid me for electricity bills and a joint gym membership. They wanted to make sure I didn’t have a secret cash stash that would disqualify me.

Those stashes are surprisingly common. Maria Benjamin, San Francisco’s Director of Below Market Rate programs, said about 20% of potential BMR homeowners are disqualified for reasons ranging from honest mistakes that understate their income to attempts to circumvent the program’s requirements.

There are far more applicants than available units, and advocates say interest is growing: Last year Homeownership SF had 5,500 people ask about it, up from 2,500 in recent years.

The city has never marketed the program, though a campaign is planned for this year. Thus far, however, information has spread mainly by word-of-mouth or community groups. That has contributed to criticism that the program isn’t attracting a diverse group of applicants.

Opponents say it ends up serving an upwardly mobile group that might only loosely be considered “middle income.” A critical Al Jazeera column said it was “effectively subsidizing upper-middle-class people to move in and paving the way for gentrification in historically low-income neighborhoods.”

Someone with low or moderate income here, meanwhile, might be considered upper-middle class elsewhere.

“We’re trying to serve working folks whose salary would otherwise be considered absolutely a livable wage, but because of this market, even that livable wage keeps them out of owning a home,” Benjamin said.

Why don’t we just build more BMR homes?

While some wonder whether the program serves the right people, others question its place in the city’s wider housing economy. In San Francisco, it has been a contentious subject for both people who want the city to build as much housing as possible and those who would rather see it retain its shape, character and communities — or protect their own investments.

Wiener wants to build more housing of all kinds. “There are people in San Francisco who have generated this myth that supply and demand doesn’t apply to San Francisco,” he said. “That is ridiculous, fantasy thinking. When we build more housing, rents come down.”

Cohen believes otherwise. His group unsuccessfully advocated to temporarily halt new development in the Mission, a fast-changing historically working-class Latino neighborhood — where the median rent for a one-bedroom apartment is now $3,600, according to Zumper — unless every new unit was affordable.

“In a neighborhood where displacement and gentrification is so acute, you’re exacerbating the problem by building luxury housing,” said Cohen. “It’s the equivalent of pouring gas on a fire.”

The map shows where the city’s BMRs are located. They are concentrated in the neighborhoods of SOMA and the Mission, where most overall development is taking place. San Francisco Planning Department

Meanwhile, nobody can agree on how much new affordable housing is enough to help sustain economic diversity while not scaring off developers. (Other cities, including New York City, have also struggled with this question.) The last time San Francisco studied that question was in 2012, when a consulting firm put the number at around 14%.

That study is to be updated later this year, though a ballot measure that passed in June already raised the city’s affordable housing requirement from 12% to 25%. That number has been called too high by some, while others wonder if it’s too low to make a difference.

The question goes to the heart of the city’s life and the challenges San Francisco faces.

Restaurants are understaffed because employees can’t afford rent. A 2014 Redfin study found that in San Francisco, where the median salary for teachers is $59,700, there is not a single home on the market that’s affordable on a teacher’s salary. City officials say housing costs make it hard to recruit teachers. The same goes for nurses, social workers, people in the nonprofit sector, and of course, journalists.

“I just don’t see how working people can ever afford to purchase in this market without this program,” said Benjamin. “In this day and age, the BMR program is a godsend.”

Home buyers in waiting

Weeks and months ticked by, and I still hadn’t moved in. I decorated my Christmas tree in the Berkeley house I shared with roommates.

I saw my condo five times over eight months. It was ready to be lived in, but vacant and collecting dust. Five months after it was ready for occupancy, only nine households of the 165 that would inhabit my building had moved in. Those delays made it complicated for buyers with leases that were ending, or who needed to pick schools for their children.

The city blamed the delays on understaffing and “a large amount of paperwork,” according to the San Francisco Business Times.

“We are a government agency,” said Benjamin. “We can’t just hire people like that.”

Today, nearly 1,500 more BMR units are approved and in various stages of development. More than 380 are opening this year. The city says it has hired more employees to approve applications.

“Things are moving much more quickly now,” Benjamin said.

Finally, in March, I moved in. I’ve met most of my neighbors: There is a flight attendant, an urban planner, a teacher, an architect, an electrician and a model. We all feel like we’d gotten incredibly lucky — and we were willing to do just about anything to stay that way.

Here’s a peek inside my 615-square foot apartment’s living room, now all moved in. Devon England for MarketWatch

One of my neighbors couchsurfed for five months because he couldn’t extend his lease at his previous apartment. Others faced hard financial decisions: One turned down a raise she was offered between the lottery and move-in so she would still qualify, while another passed up overtime because the extra money would have put her over the income limit.

While Benjamin says the city doesn’t advise applicants to do that, she admits she understands why they would. “You have to evaluate what’s worth more to you,” she said. “I’m not surprised that someone turned down a raise in favor of affordable housing.”

What if I had never happened upon the BMR program? It wouldn’t have been the end of the world: I’d be living with roommates, commuting into San Francisco, like thousands of others.

But I might have been more likely to leave the Bay Area for somewhere else -- somewhere cheaper, somewhere I could afford to buy a home, somewhere I could afford to raise a family. Now, I have more options.

My neighbors tell similar stories. They’ve gone from renting to owning. They’re building equity. Many now walk to work. Their kids can grow up in the heart of a city they love. One family of four, which was living in a studio apartment, is now enjoying their own bedrooms.

The BMR program can’t be the only solution to San Francisco’s housing affordability crisis. It’s a small, bureaucratic program facing a huge, complicated, ever-changing problem, and it’s likely to stay that way. But for the fraction of middle class residents who win a BMR unit, it can be life-changing.

One BMR program manager wrote to me after I told her my story.

“Congrats on having navigated the system,” she said, “and on drawing the golden ticket!”

This story was first published on July 5, 2016.