Facebook Inc. is extending a sizable olive branch to neighbors rankled by its plans to expand its campus and bring 6,500 new employees to the area, a move some locals fear will exacerbate a growing housing shortage.

The tech giant announced Friday it will spend about $20 million in Menlo Park and East Palo Alto, Calif., two cities that surround its campus, to create a fund to build new housing, support job-training programs and provide legal assistance to tenants in danger of eviction.

Some $18.5 million will go to a fund to build new housing, primarily targeted at low- and moderate-income families, with consultation from community groups.

Government officials and community groups in San Francisco and Silicon Valley have tried to engage tech behemoths in their backyards for help in solving the housing crunch. Costs have skyrocketed due to tight zoning restrictions that make it difficult to build and an influx of highly paid workers who are pushing out long-term residents with their ability and willingness to pay more to rent or buy.

Facebook’s decision to begin funneling tens of millions of dollars to create housing in local communities underscores the growing pressure on these companies to help tackle housing affordability, an issue that also is beginning to make it difficult to recruit employees. Companies such as Google parent Alphabet Inc. and Apple Inc. are facing similar pressures.

While about 500,000 new jobs have been created since 2010, Silicon Valley built just 26% of the new homes it needed for lower-income households between 2007 and 2014, a shortfall of nearly 22,000 homes, according to local government statistics.