The former deputy commissioner of public buildings for the General Services Administration was sentenced yesterday to four years in prison for trying to extort nearly $20,000 from a developer in return for placing a Social Security office in a shopping mall.

Lawrence F. Bretta, 56, had pleaded guilty three weeks ago. U.S. District Court Judge Andrew Caffrey in Boston agreed with the sentence proposed by federal prosecutors, noting that the average sentence on similar charges is seven years in prison.

Bretta, who resigned his $69,000-a-year job with the GSA in February after a federal probe became public, was accused of trying to extort nearly $20,000 from the East Bay Development Corp. in connection with office space at Mystic Mall in Chelsea, Mass.

According to the indictment, Bretta asked East Bay to calculate the rent for a proposed Social Security Administration office in the mall to include a $19,700 "commission" for him. The prosecution said he later agreed to accept $18,000.

Bretta then took two payments of $6,000 from an FBI agent who posed as an official of East Bay, U.S. Attorney William Weld said.

At the time, Bretta was serving as assistant regional public buildings commissioner. In a brief statement yesterday, Bretta apologized "to the General Services Administration and to its loyal and dedicated employes."