California became the first state to require companies based within its borders to put female directors on their boards, adding to pressure on boardrooms across the country to give more women a seat at the table.

California Gov. Jerry Brown on Sunday signed a bill mandating that all publicly traded companies with headquarters in the state have at least one woman on their boards by the end of next year. By 2021, companies with at least five directors would need to have two or three female directors, depending on the size of the board, according to the new law. Those that don’t face financial penalties.

“It’s high time corporate boards include the people who constitute more than half the ‘persons’ in America,” Mr. Brown said in a letter to the California state Senate announcing his decision.

Though the law would immediately affect a limited number of companies, its passage puts Silicon Valley’s startups on notice to include women on their boards as part of any plans to go public. The law would also require tech giants such as Facebook Inc. and Google parent Alphabet Inc. —which have two female board members each—to make sure to include a third within a few years, since their boards have more than six directors. (Both companies have said they are already considering women and other candidates with underrepresented backgrounds for all new board appointments.)

More broadly, the measure could accelerate the diversification of boardrooms elsewhere in the U.S., contributing to the pressure big investors like State Street Global Advisors and BlackRock Inc. are putting on companies with all-male boards to add women. In some cases, they are withholding votes for directors at companies that don’t comply.