A derelict building at 18th and Mission streets owned by a former Facebook executive that has been decaying for years has been acquired by the Mission Economic Development Agency for $6 million, with plans to add at least 40 affordable housing units to the property.

The building last sold to Owen van Natta in 2014 for $5 million.

MEDA’s purchase, which closed Dec. 7, was backed by the Low Income Investment Fund, a financial intermediary that provides capital for community developments, and the Neighbor to Neighbor fund, a local loan program.

In addition to the new units, MEDA has been working with Dance Mission Theater to relocate to the building at 2205 Mission Street, and with Mission Neighborhood Centers to open a day-care center there.

The project is expected to cost around $45 million to add six stories to the existing two and to renovate the existing structure, all while preserving the building’s historical elements.

The housing units, which are likely to number around 40, will be sold as condominiums through the city’s below-market-rate program to households making between 80 and 130 percent of the area median income. About half of them are slated to be two- and three-bedroom units to better accommodate families.

Making the units condos rather than rental units was simply a response to demand, according to MEDA.

The nonprofit runs training classes for first-time homebuyers who are looking at the city’s various affordable homeownership programs, but then those families are faced with few options.

“We get people ready to buy a home, but there’s no supply,” said MEDA’s Feliciano Vera, who is working on the project at 2205 Mission St.

Interested in a history of the building? Elizabeth Creely wrote one here.

Mission Neighborhood Centers is expected to run a Head Start program for young children in the ground-floor space, an expansion of a service it already offers. Dance Mission Theater plants to take the second floor, which will have a lobby, four studios, some offices and storage space.

“It’s not just an arts space, it’s not just housing, it’s not just childcare, it’s all three in one building. How romantic can you get?” said Dance Mission Theater’s director Krissy Keefer.

The corner building on 18th and Mission has been vacant for about seven years, during which time various proposals have been made and abandoned, including an organic grocery, a brewpub and a dialysis center.

One previous owner at one point ran into problems with the city, not just over the decay of the building, but over “unauthorized facade work.”

While the building is not strictly protected by any kind of historical status, MEDA’s current plan is to restore it to its original style.

Early estimates say the project will break ground in late 2019. But more immediately, Dance Mission Theater will aim to raise $8 million for its part of the buildout and its programming. It will have to raise this money while paying $12,500 a month in its current space, a rental cost that’s likely to rise when the center’s lease runs out in July.

Dance Mission Theater had planned to relocate to 16th and Mission streets, where a preliminary plan with a union that owns a building there would have seen the building expanded and the dance studio move to share the building with the union. But those plans were put aside when the union leadership decided to keep the building as-is, and MEDA began considering alternatives for stabilizing the dance nonprofit.

This purchase came out of MEDA’s second approach to the deal, Vera said — this time with the proposal for added housing to help make the cost pencil out.

Disclosure: Mission Local rents office space from MEDA.