The operator of a small, unlicensed nursing home in Northwest Washington, where an elderly man died of chronic diabetes four months ago, agreed yesterday to close the facility until it is inspected and licensed by city officials.

The agreement was signed by an attorney for the operator, Lucille Johnson, and the D. C. Corporation Counsel's Office and approved by a D. C. Superior Court judge. It followed an investigation of the home by District homicide investigators and city attorneys after the death of 64-year-old Sylvester Williams on Dec. 2. Williams had lived at the home at 4903 Illinois Ave. NW for two years.

At a hearing in Superior Court 10 days ago, city attorneys described the home as "in an unsanitary and unsafe condition," which Johnson denied.

Under the agreement, two of the three elderly people who were living at the home were moved yesterday to D. C. Village, the city-run home for the aged in far Southwest Washington, by workers for the D. C. Department of Human Resources. The third resident was placed in a licensed nursing home by relatives, a DHR spokesman said. Judge Fred Mc L. McIntyre approved the agreement yesterday.

The home, one of about 450 similar facilities operating without a license, is the first to be closed following action by city officials since the early 1970s.

Johnson said yesterday that she was unsure if she could afford to make the repairs needed to qualify the Illinois Avenue home for a license.

"It's quite a bit to be fixed," she said. City officials have told her she needs to install a double sink in her kitchen, a dishwasher, garbage disposal and new electric sockets, she said. "It will cost plenty," she said.

If the repairs are made to bring the home into compliance with city regulations, Johnson can apply for a license and city officials will inspect the home within 10 days, according to the terms of the agreement.

"The city got what it wanted," said Assistant Corporation Counsel Leonard Bren, who represented the city and worked out the agreement with Johnson's attorney, David Cohen. "She has agreed to come into compliance," Bren said. Cohen could not be reached for comment.

Robert Sauls, director of licensing such nursing homes for DHR, said his office would begin later this week to enforce the 1977 law that requires inspections and licenses for all homes in which one or more persons are cared for by someone other than a relative.

Because of a shortage of staff, city officials had only inspected homes when they received complaints about unsanitary conditions or improper care, Sauls said.