Office buildings are springing up all over Boston's booming downtown, and the steaming pace of residential sales has led to a 70 percent escalation in housing prices here during the past two years. But in some of the city's depressed residential neighborhoods, crumbling structures are boarded and the only brisk business is in drugs.

The liberal administration of Mayor Raymond L. Flynn wants to spread the wealth. The mayor hopes to export prosperity to Boston's blighted neighborhoods by using "linkage," a program that requires developers of large, prime commercial sites to pay fees into a housing and job training fund. In another version of linkage, developers who buy prime city-owned property also would have to build commercial or housing projects on city land in rundown sections of Boston.

Linking developers' profits with low-income housing needs, which was pioneered in San Francisco, depends heavily for its success on the kind of real estate boom Boston is enjoying.

In the Massachusetts city, one of the few in the nation where the office market still is healthy, annual rents for new downtown office buildings are in the $40-a-square-foot range, several dollars above the top rates in Washington. Some luxurious office towers in the rapidly growing financial area are renting for $60 to $70 a square foot, according to a city development official.

"We have a city that is growing and thriving, but . . . there are a number of people who are not benefiting from that economic growth . . . ," Flynn said. "We want to see that it's shared with the people in the neighborhoods. Linkage has strong political support. The only people who are opposed to it are a very few greedy developers."

The explosion in commercial development has been matched by burgeoning residential sales, touched off by plummeting mortgage interest rates. Real estate brokers and buyers are moving into the city's poorer neighborhoods, snapping up and renovating old houses.

The resulting displacement of renters has driven the vacancy rate down to an estimated 1 to 2 percent, has escalated rents and has prompted some landlords to charge three months rent as a security deposit instead of the traditional one month, said Ann Kerrey of the Boston Housing Partnerships Inc., a coalition of nonprofit organizations working with low-income housing projects.

Single-family-home prices went up by 38 percent last year alone, to an average of $144,800, and rent increases ranged from 18 to 31 percent during the same period, according to Peter Dreier, the Boston Redevelopment Authority's director of housing.

The 40 percent of Boston's population who are low- and moderate-income renters are caught in the squeeze. A linkage program was deemed a good way to help them, he said.

Commercial and office developer Robert L. Beal believes most developers "have accepted linkage as part of the cost of doing business in Boston." Beal said he supports the program as a way to provide low-income housing and neighborhood improvement "in the absence of anything else."

The mention of linkage has the effect on some Boston developers, however, that a red flag reportedly has on a bull.

"From its inception, developers have been very concerned about linkage," said Garen Bresnick, executive vice president of the Massachusetts Home Builders Association. "We're in a very hot market here and price is a very big concern." Adding linkage fees to costs "will put some projects in jeopardy."

The zoning code amendment establishing linkage, passed by the City Council two years ago, provided for a charge of $5 per square foot of a building's floor space for projects larger than 100,000 square feet to be paid over 12 years, beginning when occupancy permits are granted. When the commercial real estate market took off, Flynn signed an executive order increasing the fee to $6 paid over seven years, beginning with the start of construction, said Jerome E. Rubin of the city's Department of Public Facilities and former housing adviser to Flynn.

Linkage suffered a setback last week, when a city superior court judge struck down the zoning law amendment that created the program, ruling that Boston lawmakers did not have legal authority to approve it, and that the fee is a tax not permitted under the Massachusetts constitution.

Jerome L. Rappaport, the developer who filed the suit that resulted in Judge Mel L. Greenberg's decision, applauded the ruling. "Zoning laws are designed to provide land planning protection . . . , not to be used as a fund-raising mechanism," Rappaport said.

The developer sued Massachusetts General Hospital, charging that construction planned by the hospital would block the views of residents in his Charles River Park development and make the luxury homes less marketable. Rappaport said the hospital got permits for the massive new development by agreeing to pay linkage fees.

The city government and the Boston Redevelopment Authority have appealed Greenberg's decision.

They have argued that procedural matters, not the zoning amendment itself, were presented to Greenberg and that he exceeded his authority in his ruling, according to Albert W. Wallis, of the Boston corporation counsel's office. The city also believes it has the legal authority to enact linkage and that the fees are not a tax, he added.

Hearings planned for the spring to determine the linkage fees for a number of planned commercial developments will be held, so that, if Greenberg's decision is overturned, the projects will be "in the pipeline," said Ralph Memolo, a spokesman for the authority.

The effect on scheduled payments for the first 15 projects subject to the linkage amendment, due early in 1987, is unclear. But the possibility of borrowing against the expected payments, which the redevelopment authority had considered, "is virtually eliminated" by the court ruling, Memolo said.

The 15 developments, worth $35.5 million in fees to the city, include International Place, which will be one of Boston's biggest office buildings with 1 million square feet of offices in two towers and 70,000 square feet of shops, and Rowes-Fosters Wharves, a big condominium-office-hotel complex on the Boston harbor.

The court decision is not expected to halt the first "parcel-to-parcel" linkage deal, for which the city will soon begin to accept bids, Memolo said. The buyer of a parcel of city-owned land bordering the Boston financial district also will have to build a "substantial commercial" project in an economically deprived area, according to William D. Whitney, another Boston development official.

Net proceeds from the sale of the downtown land, after debts on the property are paid, will be given to developers for use in neighborhood construction, enabling the builders to charge below-market rents that will attract tenants, he said.