The Dow Jones Industrial Average finally closed above the 1,000 level for the first time in nearly four years with a last-minute surge near the closing bell on the New York Stock Exchange yesterday.

Stock prices had been dancing with the magical 1,000 level for several days and the Dow average briefly crossed the barrier Wednesday morning before stock prices declined anew, sending the Dow average down to a 991.04 close.

The Dow measure, the most closely watched barometer of stock prices, closed yesterday at 1,000.17, up 9.13 on the day. The last time it finished a trading day above 1,000 was New Year's Eve of 1976 when it was 1,004.65. The highest the Dow has ever closed was 1,051 in January 1973.

Since then, while consumer prices have risen more than 60 percent, stock prices have declined sharply twice, rebounding to the 1,000 level in September 1976, then again yesterday.

Other market indices yesterday also registered strong advances. The New York Stock Exchange composite index was up 0.72 to a record 80.89, and the NASDAQ composite index of over-the-counter stocks rose 1.48 to a 59.7 million shares. Standard & Poor's index of 500 NYSE stocks was up 1.34 to 140.40.

Although stock prices have been in a sustained rally since the middle of April, the election of Ronald Reagan on Nov. 4 gave investors a new impetus. The Dow average has climbed about 65 points since Nov. 5.

Trading volume was heavy yesterday, although not as heavy as it has been in recent days. About 60.2 million shares changed on the New York Stock Exchange yesterday, down from 69.2 million Wednesday and 70.4 million shares on Tuesday. Composite trading of NYSE stocks nationwide yesterday was 68.48 million.

Just after trading closed yesterday, Continental Illinois National Bank announced that it was raising its prime lending rate from 16 1/4 to 17 percent. Most banks are expected to follow Continental's lead today. Only Monday most big banks boosted their prime rates to 16 1/4 percent from 15 1/2 percent. Rising interest rates are usually the enemy of stock prices and in a normal environment, the prime rate rise could be expected to bring down stock prices today.

But since the Reagan election, investors have not been behaving normally, shrugging off both rising interest rates and indications that a new economic downturn may be beginning -- a development that hurts corporate profits and, therefore, stock prices.

"I still feel the market has moved awfully fast," said Leslie J. Silverstone, head of the Dean Witter Reynolds Washington office at 1776 K St. NW. "I sense that some of the smarter people are taking profits. There was good volume today, but on a day in which the Dow breaks 1,000 I would have thought there would be more. That is evidence that some investors are taking greater caution."

Silverstone said he was taking the leap above 1,000 "with a grain of salt. The move is not as bullish as it would have been if there were more industries advancing." Silverstone said the number of industries whose stocks have been rising in price has been shrinking in recent weeks.

But Patrick C. Ryan -- head of trading at the Washington firm of Johnston, Lemon & Co., Inc. -- said there is "a lot of strength in the market," although he disagrees with more ebullient analysts who thinks the market is poised for a climb to a Dow average of 1,100 in a short period of time. "But for the long haul there's no doubt the arrow is pointing up."

On the New York exchange, the number of stocks rising in price exceeded those declining by 880 to 716.

On the Amercian Stock Exchange, the index was up 4.56 to 360.28, with 340 issues rising in price and 311 declining.

Among the most active New York Stock Exchange issues were Texaco, which closed up 3 1/4 to 48 7/8; Arlen Realty, which closed up 1/8 to 3 1/4; Sony Corp., which gained 1/2 to close at 16 5/8; and Federal National Mortgage, unchanged at 11 3/4 after a steep decline that followed a halving of FNMA's dividend rate.

Dynalectron, of McLean, was the third-biggest percentage gainer on the Amex, up 2 1/8 to 17 3/8 on a volume of 288,800 shares that reflects investor interest in the firm's oil-from-coal energy process.

Analysts said that the next few days will be critical ones for the current stock market rally. If the profit takers are not able to drive prices down -- that is, if there are enough buyers around to absorb shares being put on the market -- then stock prices could build a "base" around the 1,000 level from which they could climb higher.

If the sellers prevail, then prices could go down somewhat before the market recoups and begins to climb again.

Some so-called technical analysts who look to trading patterns rather than fundamentals to predict the future think the market is near the top and will begin to slide soon, although not to the 800 level that prevailed last spring.