A four-year dispute between Blake Construction Co. and Montgomery County over the county's refusal to pay construction cost overruns on a government center in Rockville has been settled out of court for $5.25 million, which includes money that the county had withheld, county officials said yesterday.

The settlement will halt a $20 million suit filed by Blake against the county two years ago in U.S. District Court in Baltimore.

However, related litigation brought by the county against the architects who designed the complex will continue, said Peter Barnes, whose law firm was brought in by the county to handle that aspect of the case.

Blake asserted that expensive alterations and design changes in the county executive offices and judicial center in Rockville had caused the overruns and were the result of deficiencies in the architects' specifications and faulty geological data.

County officials, in filing the third-party suit against the architects, have tacitly agreed. The court ruled, however, that the county's claims could not be heard until the basic dispute was decided.

County officials had withheld approximately $1.7 million for work done by Blake and $1 million to cover the estimated cost of the change orders.

The actual settlement costs amount to about $2.5 million in unbudgeted money -- a cost that county attorneys had concluded would be exceeded by continuing the court case.

"It's been a long suit, and I'm glad to have it settled," said County Executive Charles Gilchrist last night. Gilchrist said County Council members have concurred in the settlement.

Justin Simon of Dickstein, Shapiro & Moran, the attorneys for Blake Construction, agreed: "We are very glad that the litigation, which is enormously expensive, has been ended, and the company is also very pleased to have been able to reach an agreement with the county, as they would be with any customer."

The issue of the construction costs had gathered political resonance during the 1982 election, when Republican candidates accused Gilchrist's administration of having mismanaged the project.

An earlier similar settlement had been at least tentatively negotiated before the suit was filed, county sources said, but the County Council refused to appropriate the money.

Court records filed by Blake indicating that they believed the earlier settlement had been breached, put the original agreed upon figure at $6.2 million.