Caltrain already planned to build a more modern commuter railroad with new trains and electrified rails, but directors decided Thursday that it should also include trackside housing — and much of it will be affordable.

The three-county board that runs the 156-year-old railroad unanimously agreed that it’s time to develop housing where it can be squeezed in along Caltrain’s 51-mile right of way.

The transit-oriented development policy, created after a series of sometimes contentious meetings with housing advocates last year, lays out a framework for building along the tracks. Caltrain officials acknowledged that it might be more profitable to sell off the land to office or hotel developers, but directors said the need for housing — and affordable housing — is paramount.

“Profit should not be our primary motivation,” said Ron Collins, a board director and San Carlos mayor.

The policy will require 30% of each transit-oriented housing development to offer below-market rent. At least 10% of units will be reserved for households with no more than 50% of median income, 10% for households below 80% of median income, and at least 10% for households with incomes of no more than 120% of median income.

Housing advocates had urged the board to raise the affordable housing requirement from an original suggestion of 20%, and many praised the policy while thanking board members for backing the addition of affordable housing on public land.

“You all are not the only ones we were picking on,” said Leora Tanjuatco, organizing director of the Housing Leadership Council of San Mateo County. “It’s a statewide effort. When we have nurses sleeping in their cars, when we have people driving three hours to work, it is unconscionable to build hotels or offices on public land.”

Other transit agencies, such as BART, also have ambitious goals, such as 35% affordable housing systemwide and at least 20% on each project. However, the regionwide rail system has run into community opposition when it has proposed developments around stations.

Caltrain has considerably less development opportunity than BART, said Brian Fitzpatrick, Caltrain’s real estate and property manager. While BART has at least 250 acres it can build on, Caltrain has just two sites that could accommodate significant development: Mountain View and Redwood City stations. Those sites make up less than 5 acres total. Several other sites are considerably smaller and often consist of little more than an acre.

Because of the limited development potential, Caltrain’s board also decided that residential buildings should have a minimum of four stories and include at least 50 units per acre.

Neither of the sites has a specific proposal yet, and any development plan will have to be approved by the board, so community opposition may still surface — especially since they would likely require the loss of hundreds of Caltrain parking spaces.

Michael Cabanatuan is a San Francisco Chronicle staff writer. Email: mcabanatuan@sfchronicle.com Twitter: @ctuan