The London Lighthouse charity for people with HIV and AIDS has won its battle to stay in its purpose-built premises in Notting Hill, west London. But its residential services will close at the end of September.
The charity's managers accepted a 2m rescue package on Monday, under which part of the building will be sold to the Notting Hill Housing Trust.
The residential unit will be converted into family homes and flats for people with special needs, including people with HIV and learning difficulties.
The deal means that Lighthouse will be able to continue to offer day care, drop-in services, child care and complementary therapies from its building instead of having to transfer the services to another site.
The building was put on the market in May after the withdrawal of 1.7m of NHS funding made continuing the charity's residential care services unviable.