Like generations of garment workers before him, Max Hernandez came to New York City to get his start behind a sewing machine.

Only he could not find any work. After more than a year of looking, Mr. Hernandez, 25, finally spotted a Craigslist ad for a $12-an-hour sewing job with UZI, a tiny company in Sunset Park, Brooklyn, that makes dresses for Anthropologie, among others.

“New York City is the center of the fashion world, but hardly any of it is made here,” said Mr. Hernandez, who beat out a dozen other applicants for the job. After several promotions, he now makes $15.50 an hour.

As Fashion Week unfolds on glittering runways this week, the city’s once-thriving garment manufacturing industry has little to celebrate. Many companies are struggling with rising rents and labor costs and outdated work spaces and losing business to competitors overseas who can make clothes more cheaply. Block after block of factories and showrooms have disappeared from the renowned garment district in Manhattan, replaced by technology, media and consulting companies that focus on the design and marketing side of the business, if they are even connected to fashion.

There were just 22,626 city residents age 16 and older making apparel, accessories and finished textile products in 2015, a small fraction of the peak of 323,669 workers in 1950, and less than half of the 59,049 workers in 2000, according to an analysis of census data by Queens College.

But now the troubled garment industry is getting a lifeline. New York City officials have stepped up efforts to create a new, modern garment district — this time in Sunset Park, where large industrial buildings, affordable rents and easy access to transit lines and parking have already attracted dozens of manufacturing companies. A $115-million renovation of the city-owned Brooklyn Army Terminal, a former military supply base, will expand manufacturing space there by 500,000 square feet this fall.

City officials have partnered with the Council of Fashion Designers of America, a leading fashion industry group, to help companies across the city modernize their manufacturing processes and workplaces. A joint program, the Fashion Manufacturing Initiative, has awarded $1.8 million in grants to 19 companies since 2014 to pay for technology like 3-D printers to create accessories, pattern-making and fabric-cutting software that results in less wasted fabric, and equipment that combines the fabric cutting, embroidering and stitching into one step.

A city-financed marketing and advertising campaign — “Made in New York’’ — that promotes film and television productions and technology companies has been expanded to highlight locally made fashions with advertisements on newsstands, bus shelters and in Women’s Wear Daily, a publication that covers the industry.

“Everybody thinks of fashion as all glitz, but this is a homegrown industry with everyday New Yorkers working behind the scenes,” said Alicia Glen, deputy mayor, who oversees the city’s economic development. “Fashion manufacturing puts food on the table for tens of thousands of families. And it needs room to grow. What’s ‘Made in New York’ is good for New York.”

Currently, there are 1,568 garment manufacturing companies in the five boroughs. The largest concentration, 419 companies, remains clustered in or around the garment district, even as manufacturing space there has shrunk to 830,000 square feet from 1.1 million square feet as recently as 2009.

“The streets used to be lined with trucks that were picking up or delivering to the garment district,” recalled Frank Dara, 71, who spent decades cutting fabric for companies. “Today, if you see 10 percent of what it used to be, that’s a lot.”

Steven Kolb, the chief executive of the Council of Fashion Designers of America, said local garment manufacturers were as vital as ever to the city’s fashion industry. Local companies are often more willing to accept small orders and take chances on new designers than overseas manufacturers, he said. They can also turn around clothes more quickly, and their proximity allows designers to monitor production more closely.

“The closer you are to production, the better,” said Mr. Kolb, adding that it was the difference between having “a long-distance relationship with a boyfriend in L.A.” and one in which “you live in the West Village and he lives in the East Village.”

For many companies, the biggest hurdle is finding a place they can afford. UZI has hopscotched from one home to another on the Lower East Side and in Brooklyn, moving each time the rent increased. Today, it makes about 600 dresses a month in a 900-square-foot studio in a walk-up building in Sunset Park. It is so cramped that fabrics have to be stored in another building three blocks away.

“You know how heavy a bolt of fabric is?” said Mari Gustafson, a co-founder of UZI. “Three long blocks with 70 yards of fabric on my shoulder is going to eventually lead to my body falling apart. The main challenge is getting enough space at a reasonable price.”

More than 100 garment manufacturers have settled in the Sunset Park area, including 10 companies that lease space at below-market rates in the sprawling Brooklyn Army Terminal and another city-owned building. Last month Mr. Kolb took 25 factory owners on a tour of Sunset Park, saying that in the last decade more companies have become willing to leave Manhattan.

On a recent morning, jackets were being assembled by women behind Juki industrial sewing machines at Bestec Concept in the Army Terminal. The company, which makes military uniforms, opened a second production site in the 37,500-square-foot space last year after running out of room in its Queens factory.

A $300,000 machine that cuts fabric with lasers sat nearby, ready to do the work of three people; its cost was partly covered by a grant from the Fashion Manufacturing Initiative. Peter Kim, 46, a co-president of the company, said the machine — the size of three pool tables — would not have fit in the Queens factory, but at the Army Terminal, it was simply loaded onto a huge freight elevator and rolled out onto the floor.

Malia Mills is another recent arrival in Sunset Park. Ms. Mills, 50, moved her company to an 11,000-square-foot loft in Industry City, a complex of redeveloped buildings, in 2014 after it outgrew its previous home in the garment district.

Ms. Mills now has enough space for a “fabric library” and plans to add more sewing machines and equipment. She declined to disclose her rent, saying only that it was about half as much as what she previously paid. She has used the savings to expand her business, including opening two new stores in California and a temporary pop-up store in Houston. “I wish we had done it sooner,” she said of the move.

There has also been an unexpected benefit: neighbors with skills other than fashion. She has called upon a pillow manufacturer, a furniture maker and a technology consultant, among others, for help and ideas about running her business.

“You are learning from one another,” she said. “There is a diversity of products and mind-sets that you find out here that is amazing. It has broadened my perspective.”