When a local nonprofit announced a lottery for a new batch of rental subsidy vouchers this month, applicants jammed the lobby — young and old, black and white, immigrant and Boston-born. Some were homeless families living in cramped motel rooms; others were single moms hoping to move their children to safer neighborhoods.

Boston and much of the rest of Massachusetts are in the midst of an affordable housing shortage that shows few signs of abating. The rate of new housing production in Massachusetts is among the lowest in the country, with luxury units in the booming downtown and beyond expected to make up the vast majority of new apartments built in Boston in the next three years. One in four renters in the state spend at least half their household income on rent — considerably higher than the one-third recommended by financial specialists.

Housing subsidies have been slashed, shelters are over-capacity, and the homeless population is increasing faster
than in any other state in the country, according to the US Department of Housing and Urban Development. More than 21,000 Massachusetts residents are homeless, a 40 percent increase in the past seven years.

Get Talking Points in your inbox:

An afternoon recap of the day’s most important business news, delivered weekdays.

Among them is Dineen Duro, 31, who has been living in the Days Hotel in Brighton with her young son for two years, one of nearly 5,000 families the state is housing in emergency shelters and motels. She estimates she has applied for about 50 kinds of housing assistance during that time.

Duro knows the odds of landing a rental voucher are long, but she’s hoping for “a little bit of normalcy.”

“This way, me and my son aren’t crammed into one tiny little room,” she said. “And this way I can actually cook dinner. There’s not much you can do with a microwave.”

Duro said she is in a daily substance abuse program to kick her painkiller habit, and hasn’t been able to find a job that fits into that schedule.

She went to the Metropolitan Boston Housing Partnership office earlier this month wearing a red bandana over her hair, nose pierced and eyes dramatically lined to apply for one of the slots in the Massachusetts Rental Voucher Program. The recipients, chosen by lottery, will be notified next week.

The state has 6,600 rental vouchers to help low-income families pay for apartments, a third of what it had in the early 1990s, due to budget cuts, according to Massachusetts housing officials. The number of vouchers has risen modestly over the last few years, but not nearly enough to keep up with demand.

Residents awarded a voucher pay up to 40 percent of their income toward rent, and the voucher, which can be used only at lower-priced units, covers the rest. To qualify, a household must make less than 50 percent of the median income of Boston-area residents – below $42,350 a year for a three-person household. The average annual income of families who currently have vouchers: $13,000.

“The situation continues to worsen for families at the lowest income levels,” said Chris Norris, executive director of the Metropolitan Boston Housing Partnership. “Our fear is that if we don’t get more resources, the state rental voucher wait list will look like our Section 8 wait list, which is 11 years long.”

Josh Reynolds for The Boston Globe

Richard Beaupre, his fiancee, and their two daughters headed back to the Malden motel where they have been staying. They are among 10,000 applicants for a rental voucher.

Section 8, a federal housing voucher program, limits monthly rent payments of low-income families to 30 percent of gross income. Last year, budget cuts eliminated more than 1,400 of the state’s Section 8 vouchers, making the shortage more acute.

Federal funds for building affordable housing in the state were also sliced in half last year. The Boston Housing Authority has a wait list of 40,000 households for 15,000 subsidized units.

Massachusetts does more for low-income residents in need of housing than many other states, said Aaron Gornstein, the state’s undersecretary of Housing and Community Development. It is one of the only states that fund public housing, for instance, and has a program to preserve affordable units.

Still, many families are struggling to keep a roof over their heads.

Marta Diaz, 44, has lived in public housing in Dorchester for 17 years, and currently shares her four-bedroom apartment with three daughters and two grandchildren. But the neighborhood is unsafe and the apartment is run down, said Diaz, who is about to be laid off from her nursing home job in Brookline.

“The crime rate is so high,” said Diaz, who was filling out an application for one of the newly available rental vouchers. “I don’t have the money to afford somewhere else to live.”

To help meet the growing need in Boston, Mayor Martin J. Walsh has committed to creating 6,500 new units by 2030 aimed at families making less than 60 percent of the median income — with a quarter of those designated for even lower-income households.

The annual median income for a renter in Boston is around $35,000, or about $3,000 a month, according to Michael E. Stone, professor emeritus of community planning at the University of Massachusetts Boston. The average rent for a one-bedroom apartment in the city is almost $2,000 a month.

Richard Beaupre is another of the 10,000 applicants waiting anxiously to see whether he will win a voucher. Beaupre, 28, has been living in the New Englander Motor Court
in Malden with his fiancee and two daughters, ages 1 and 2, since February, and he’s desperate to get out.

The family sleeps on two beds pushed together. Their clothes are in suitcases; their pasta dinners are boiled in the microwave. Beaupre, who was laid off from a retail job and then evicted from his apartment, walks 2 miles down Route 1 to get to his $9-an-hour job at the Disney Store at the Saugus mall.

Recently, Beaupre’s oldest daughter pointed at the motel from her stroller and said, “Home.” Beaupre was quick to correct her. “That’s not home, sweetie,” he said. “That’s a room.”