The population of the District rose slightly last year for the first time in more than two decades, according to U.S. Census Bureau estimates.

The city's population was 626,000 in mid-1985, the Census Bureau reported, up 1,000 from a year earlier, when the bureau said the population here had leveled off after a long, steep decline.

Although no census data by race was available, demographers suggested that the apparent turnaround has been caused by a stabilizing of the black and the white populations, while the number of Hispanics, including illegal aliens from Central America, has increased substantially.

The new census estimates are based on several complex formulas, using birth and death statistics, housing unit and school enrollment reports and data from income tax returns and Medicare and immigration records.

Edwin Byerly, the Census Bureau statistician who prepared the new figures, said the formulas include estimates of illegal aliens for the first time.

The Census Bureau has revised slightly upward all its previous population estimates for the District since 1980, when 638,333 residents were counted here. But Byerly said this does not change the basic pattern, showing small population losses from 1980 to 1983 and a leveling off in 1984.

During the 1970s the District's population dropped by 118,000, or 15.6 percent. The last time it increased was in 1963, when it reached an estimated 798,000. But even this was well below the peak of 900,000 in 1943.

"There appears to be an upturn, which is a rather important piece of information," said Donald E. Starsinic, chief of the Census Bureau's population estimates branch. "We'll keep our fingers crossed that it continues."

Starsinic said the major movement of black families to the suburbs that occurred during the 1970s appears to have abated, possibly a result of improvements in the D.C. public schools.

Gan Ahuja, the District government's chief demographer, added that the loss of whites -- which slowed in the 1970s after massive drops in the 1950s and 1960s -- appears to have stopped.

He said more whites in their twenties and thirties are staying in the District and having children, though the numbers involved are still small.

According to D.C. government estimates for 1984, there has been virtually no change since 1980 in the city's racial composition, which was just over 70 percent black.

There are no recent estimates by D.C. officials or the federal government of the District's Hispanic population, which came to 17,679 or 2.8 percent of city residents counted in the 1980 census. Most Hispanics are classified by the Census Bureau as whites.

However, the D.C. public schools report a rise in Hispanic enrollment from 1,336 in 1980 to 2,951 last fall. Virtually all of the increase took place in the past three years, much of it composed of refugees from El Salvador and other Central American countries who have streamed into the Washington suburbs.

"There are a large number of illegal Hispanic immigrants," Ahuja said, "though no one can say for sure how many are here."

The new Census Bureau report shows continued moderate population growth in Maryland and Virginia.

In Maryland the estimated population last July was 4,392,000, up 43,000 in a year and 175,000 or 4.2 percent since the 1980 census. In Virginia the population rose last year by 70,000 to 5,706,000, a gain of 359,000 or 6.7 percent since 1980.

The growth rate is up slightly in Maryland compared with the 1970s, but down slightly in Virginia.

The District figures were issued by the Census Bureau along with those of the states, but no 1985 estimates have been reported for individual cities or counties.

Based on 1984 estimates, the population of many big cities, including New York, Boston, San Francisco and Denver, which fell sharply during the 1970s, is rising slightly in the 1980s. In others, such as Baltimore and Richmond, losses have tapered off. Nonmetropolitan areas and distant suburbs are growing less rapidly than in the previous decade.

The overall population of the United States reached 238.7 million in mid-1985, an increase of 2.2 million in a year and 12.2 million or 5.4 percent since 1980. The Census Bureau said national population growth is about the same as in the 1970s.

The South and West continue to account for about 90 percent of growth, though the Northeast has made a modest rebound. However, states dependent on farming or energy production -- both depressed sectors of a generally buoyant economy -- have been stable or lost population. Last year the latter group included Iowa, Pennsylvania, West Virginia, North Dakota and Oklahoma, as well as Wyoming, which fell behind Alaska to become the least populated state.

George W. Grier, a demographer who has prepared major reports for the Greater Washington Research Center, noted that Arlington and Alexandria showed slight population gains from 1980 to 1984. Both share many central-city characteristics with the District and also lost population during the 1970s.

In all three jurisdictions, Grier said, most of the population losses were caused by a decrease in average household size as traditional families with children were replaced by singles, childless couples and single-parent homes.

"Most of those who were going to leave the District seem to have left," Grier said. "Household size has to stabilize at some point . . . . Now I expect the District is going to grow slowly, at least to the end of the decade.