Martin Marietta Corp., bucking the trend of declining earnings for defense contractors, yesterday reported a 9 percent increase in its second-quarter profits and an 11 percent gain for the first half.

The Bethesda-based company said its bottom line was bolstered by several major programs, primarily the Titan IV rocket and the LANTIRN night vision and targeting system for jet fighters.

For the second quarter, Martin Marietta said its profit totaled $94.5 million ($1.85 a share), compared with $86.9 million ($1.64) for the same quarter a year ago.

Revenue for the second quarter was $1.66 billion, up 15.6 percent from $1.43 billion for the second quarter in 1989.

The company reported first-half earnings of $161.6 million ($3.17), compared with $146.13 million ($2.76) for the first half of 1989.

Revenue totaled $3 billion in the first half, an 11.9 percent increase from $2.7 billion for the same period last year.

Martin Marietta stock closed at $39.75 on the New York Stock Exchange yesterday, down 12 1/2 cents.

ERC Environmental and Energy Services Co. said the one-time costs of closing one of its divisions pushed its earnings down for the second quarter and first half.

The Fairfax-based company reported second-quarter earnings of $358,000 (7 cents), compared with $901,000 (16 cents) for the same quarter a year ago, including the discontinued operations. Its revenue rose 21 percent in the quarter, to $20.8 million from $17.2 million.

The one-time charge of $729,000 covered the cost of discontinuing its Digital Conversion Division, which converted drawings into digitized computer images.

The Roanoke-based unit, whose customers were mostly utilities, was in a price-competitive field that ERC Environmental decided did not fit with the thrust of its business and did not offer growth potential as strong as environmental services, company President J. Mark Elliott said.

ERC Environmental reported a first-half profit of $1.2 million (23 cents), down 26 percent from 1989 first-half earnings of $1.65 million (31 cents). Revenue increased 17 percent in the half, to $39.6 million from $33.7 million.

Ameribanc Investors Group, the holding company for a Northern Virginia thrift with $1.4 billion in assets, reported a 90 percent decline in earnings for the second quarter and a loss for the first half, in part due to the continued deterioration of commercial real estate markets.

Annandale-based Ameribanc said the 1989 second-quarter results were skewed by a one-time gain of $2.1 million on the sale of securities. The thrift earned $203,000 (3 cents) in the quarter, compared with $2.1 million (32 cents) in the 1989 second quarter.

For the first half, Ameribanc lost $2.9 million, compared with 1989 first-half profits of $5.2 million (79 cents).

The company said its nonperforming assets -- those not earning interest -- rose 22 percent in the second quarter, to $86.1 million from $70.5 million in the 1989 second quarter. The thrift took about $600,000 in write-downs during the quarter to cushion against potential loan losses, and it reported a $3.1 million first-quarter loss on the recognition of nonperforming loans.

Among the bright spots, Ameribanc said, was a 6.5 percent gain in net interest income, a 23 percent increase in earnings from service charges and a $900,000 gain from the sale of mortgage servicing rights.

The thrift said it reduced its balance of foreclosed property by $6.6 million during the quarter through the sale of three major properties and that it reduced operating expenses through cost-cutting initiatives.

Alex. Brown Inc., the Baltimore-based investment banking company, said growth in its retail brokerage and capital markets businesses pushed its profit up 6.6 percent in the second quarter.

The company earned $4.5 million (29 cents) in the second quarter, compared with $4.2 million (26 cents) in the 1989 second quarter. Revenue rose 9 percent in the quarter, to $77.2 million from $70.8 million.

For the first half, Alex. Brown reported a profit of $7 million (44 cents), compared with a $2 million loss in the 1989 first half. First-half results for 1989 were skewed by a $6.9 million after-tax charge related to expected losses in eliminating excess office space, the company said.

Revenue rose 11 percent in the first half, to $145.7 million from $130.9 million.