Federal and District officials have reached a key agreement designed to preserve the historic character of Washington's Union Station, removing one of the last obstacles to a multimillion-dollar renovation of the dilapidated railroad terminal complex.

The three block long structure, which has been closed since 1981 because of leaks in its roof and other hazards, is expected to be overhauled at a cost of nearly $140 million in federal and private funds. It is to contain restaurants, shops, offices and movie theaters along with railroad facilities.

Officials said the new agreement, drawn up after months of negotiation, had settled most of the disputes over the project. Historic preservation officials initially had objected to the architectural plans, saying they put excessive emphasis on commercial development.

"The design has changed substantially," John Cullinane, a senior architect for the federal Advisory Council on Historic Preservation, said yesterday. "Now the shopping enhances the architecture. It doesn't overwhelm it."

Keith Kelly, executive director-president of the Union Station Redevelopment Corp., a federally backed nonprofit firm set up to oversee the project, said the accord will allow construction to start soon. The renovated station is scheduled to reopen in August or September 1987, he said.

The agreement provides for a series of modifications in the initial plans, chiefly to eliminate retail and other structures regarded as likely to mar the building's classic features. For example, a proposed mezzanine is to be narrowed to ensure "greater openness" and to enhance "the grandeur of the space."

One provision, cited as a significant improvement by preservation officials, will require the Federal Railroad Administration and the Union Station Redevelopment Corp. to "monitor and enforce compliance" with the agreement after the station reopens to prevent "potential deviations" in the future.

The redevelopment project was launched by federal officials in 1983. Work already is under way to complete a long-unfinished five-tier parking garage behind the station. Some initial repairs also have been carried out to prevent further deterioration.

Recently, officials discovered what has been described as a relatively small amount of asbestos, a hazardous substance, in insulation around pipes in the building's basement and second floor. Kelly said the material will be removed before renovation work starts. Tests found no asbestos particles in the air inside the building, he said.

Shortly before its closing, the station, built in 1907, was converted into a widely criticized National Visitor Center with a large pit in its main waiting room for an elaborate slide show. Demolition crews will start removing the visitor center's structures in about three months, Kelly said.

Major renovation work is scheduled to begin in April. Although sweeping changes are planned inside the building, the white granite exterior is to be preserved. Officials have said they plan to recreate the bustling atmosphere and elegance the station had in its heyday.

The new agreement limits the use of trees, fountains, kiosks and other structures considered likely to clutter the building. No major reduction in retail outlets was required, although some proposed storefronts were drawn back. Subdued lighting, reflecting from the ceiling, is to be installed.

Officials agreed to study possible installation of a major artwork or railroad museum exhibits in the main hall.