President Reagan's fiscal 1987 budget is expected to propose Defense Department spending increases of nearly 40 percent over five years, plus a hefty boost for the space program. But most civilian agencies would be cut substantially or frozen in place, according to budget documents obtained yesterday by The Washington Post.

The documents confirm that Reagan, when he presents his budget proposals on Wednesday, will insist on a continuous military buildup over the next five years while tightening the noose around civilian programs, except for Social Security and a few select others.

The documents were dated Jan. 29, at the point that the budget went to the printers. Sources said the documents accurately reflect the printed budget, although minor changes might have been made.

The documents did not spell out which programs within a department would be cut; reports have circulated that the president would seek major reductions in some Medicare payments in an effort to slow the program's growth, cuts in medical research, cuts in Amtrak and various housing and loan and community aid programs. The documents do indicate that the Small Business Administration would be eliminated.

Many of the proposed eliminations or cuts have been rejected previously by Congress, and key members of Congress have predicted that the Reagan budget will be dead on arrival.

Edwin L. Dale, spokesman for the Office of Management and Budget, had no comment on the documents.

The documents indicate that for fiscal 1987, Reagan is proposing total outlays of $994 billion against government receipts of $850.4 billion, for a deficit of $143.6 billion.

That is just below the $144 billion deficit limit for fiscal 1987 required by the Gramm-Rudman-Hollings act. The documents project that the deficit will drop each year until a $1.3 billion surplus is achieved in 1991.

According to the documents, the Department of Health and Human Services would receive an increase. But almost all of it, sources said, reflects growing Medicare outlays despite a pruning of some payment provisions. Other HHS programs would be frozen or cut.

According to the documents, Defense Department outlays, excluding certain other defense expenditures handled by other agencies, such as nuclear warheads, would rise from $258.4 billion in fiscal 1986 to $274.3 billion in fiscal 1987, $290.7 billion in 1988, $313.3 billion in 1989, $335.5 billion in fiscal 1990 and $356.6 billion in 1991. That roughly corresponds to a real rate of growth -- after inflation -- of about 3 percent a year. The National Aeronautics and Space Administration would rise from $7.3 billion in 1986 to $9.5 billion by 1991.

On the other hand, education, transportation, environmental protection and agriculture would receive less money in 1991 than in 1986, which, in view of the loss of purchasing power because of inflation, will mean sizable cuts in program levels. Most other civilian departments, while receiving slightly more money, would not keep up with inflation.

The Education Department, at $17.8 billion in fiscal 1986, would drop to $14 billion by 1991. Over the same period, the Transportation Department would drop from $26.3 billion to $22.2 billion, Housing and Urban Development from $15.2 billion to $12.7 billion, the Interior Department from $4.6 billion to $4 billion and the Environmental Protection Agency from $4.6 billion to $3.6 billion.

The Agriculture Department, with outlays reduced from $54.2 billion in 1986 to $35.8 billion in 1991, would take the biggest cut. Sources said major reductions would be proposed in farm credit and rural housing, and lower costs for price support operations.

In the current fiscal year, according to the documents, total government spending will be $979.9 billion, after deducting the $11.7 billion automatic cut required by Gramm-Rudman-Hollings, and also after deducting about $2.3 billion that the president is proposing to rescind from amounts appropriated by Congress.

Although outlays for many civilian agencies would be cut over the five-year period, much of the deficit reduction would actually result from higher tax receipts.

And, although Reagan has said he opposes any increase in personal income taxes, the documents predict that business taxes will rise from $70.9 billion in 1986 to $125.6 billion in fiscal 1991, and individual income taxes from $354 billion in fiscal 1986 to $516 billion in fiscal 1991. These increases appear to reflect optimistic administration projections for economic growth, which some economists believe may be too rosy.

Asked for comment on the projected budget, Dr. Gary Bass, director of OMB Watch, a nonprofit organization that studies budget issues, said that if the figures obtained by The Washington Post are correct, "What we have is disproportionate cuts of middle-class programs -- in housing, education, state and local government aid, health programs, revenue aid to the localities, community development, and basic services in commerce and transportation.

"On defense, on the other hand, we now know that [former OMB director] David Stockman was right: it is very difficult to convince this president that defense spending must be restrained. The lines are going to be drawn in Congress."

It is uncertain that Congress will grant Reagan the military increases he wants. Sources said yesterday that he will ask $320.3 billion in new budget authority for all defense functions -- including some functions outside the Department of Defense -- in fiscal 1987. This figure is higher than the $274.3 billion DOD outlay figure projected in the budget documents because part of the new budget authority is for other, defense-related agencies, and because authority and outlays don't always correspond in a given year because expenditures on some items are spread over several years.