Encouraged by falling interest rates and decreasing chances of recession, the stock market moved strongly upward yesterday.

On a day when foreign stock markets declined and the dollar fell sharply, the Dow Jones industrial average climbed 40.12 points to close at 1985.41, a 2.1 percent increase. The Dow ended the day 47.08 points higher than its close one week ago, but slightly below where it started this week.

Market analysts said buyers were encouraged by the decision by major U.S. banks to lower their prime interest rates by one-quarter point, to 8.75 percent. It was the second rate reduction since the current market trauma began nearly three weeks ago.

But the good news on interest rates wasn't strong enough to overcome underlying anxieties in the market, analysts said. "We lose points so quickly these days that people are hesitant to jump back in," said Kenneth Schmolze, technical analyst and vice president of Thomson McKinnon Securities Inc. "The market has been positive over the last couple of weeks, but there is still a lot of nervousness."

The day began with sharp declines in overseas markets, and the Dow hovered around its opening level of 1945.29 during much of the morning. It started rising after noon and at one point was up more than 66 points. Bonds and stock futures also moved generally upward during the day.

Among other market indexes, the New York Stock Exchange composite index was up 2.70 to 141.81, a 2 percent increase, and the American Stock Exchange composite index rose 2.88 points to 255.05, a rise of 1.1 percent.

On the New York exchange, volume was nearly 226 million shares. Advancing stocks outnumbered declining issues by a 3-1 ratio.

The broad rise in the U.S. markets contrasted with the results on major markets elsewhere in the world. Prices were down sharply in Tokyo and Hong Kong, and fell moderately in Paris, Frankfurt, Zurich and Brussels.

The 508-point NYSE plunge of Oct. 19 was preceded by sharp drops in markets abroad, but experts suggested that the U.S. markets and their overseas counterparts are listening to different signals now.

"There is less linkage. It would take a really horrible {overseas} plunge to shake up the U.S. market at this point," said Hildegard Zagorski, associate vice president at Prudential-Bache Securities Inc. "There is money around that realizes a lot of these {U.S.} stocks are undervalued."

Investors also were encouraged by reports that the Reagan administration would allow the dollar to fall in response to lower interest rates in order to stave off slower economic growth, even at the potential cost of higher inflation. As a sign that the markets are not yet fearful that a lower dollar will lead to higher inflation, gold stocks and the price of the metal itself closed lower yesterday. Investments in gold are considered insurance against inflation.

Some analysts suggested that while U.S. markets are skeptical about deficit-reduction talks between the Reagan administration and Congress, foreign markets are looking for a significant cut in the federal budget deficit. European leaders have said the United States has to reduce its budget and trade deficits before they will stimulate their economies.

"Fiddling with interest rates is not going to do anything to the {overseas} markets unless something really fundamental is done. From a European perspective, that means fundamental changes in the U.S. economy," said Dennis Elliott, first vice president of UBS Securities, an international capital-markets firm that is a subsidiary of the Union Bank of Switzerland.

Some of the biggest gainers yesterday were blue-chip firms, capital-goods companies and other exporters that could benefit from the lower dollar, which reduces the prices of U.S. goods and services overseas. International Business Machines was up 4 3/8 to 123 7/8, Goodyear Tire & Rubber rose 3 points to 48 1/8, Caterpillar climbed 3 5/8 to 55 1/4 and Dow Chemical went up 3 7/8 to 73 5/8.

Among local companies, Marriott rose 1 point to 30 3/4, Fairchild was up 1/4 to 9 1/4 and Federal National Mortgage Association climbed 1 5/8 to 34 5/8. A.H. Robins of Richmond, which lawyers charged yesterday may have inadequate reserves to cover claims for damages related to its Dalkon Shield birth-control device, fell 1/8 to 20 7/8.