Stocks ended the first half of 2004 with moderate gains Wednesday as the Federal Reserve's widely expected interest rate hike and reassuring statement quelled investor worries about rising interest rates.

The Dow Jones industrial average (searchgained 22.05 points, or 0.21 percent, to 10,435.48, after a day in which it swung 95.57 points, rising as high as 10,471.24 and as low as 10,375.67. The Standard & Poor's 500 Index (searchgained 4.55 points, or 0.40 percent, to 1,140.75. The technology-laced Nasdaq Composite Index (searchgained 12.86 points, or 0.63 percent, to 2,047.79.

For the month of June, the Dow added 2.4 percent, the S&P 500 advanced 1.8 percent and the Nasdaq climbed 3.1 percent.

For the second quarter, the Dow ticked up 0.8 percent, the S&P 500 gained 1.3 percent and the Nasdaq shot up 2.7 percent.

The Fed's first rate hike in four years moves the benchmark federal funds rate — which affects credit costs throughout the economy — up to 1.25 percent from 1 percent, a 46-year low.

"This has certainly been a very well telegraphed change in direction," said Jack Caffrey, equities strategist at J.P. Morgan Private Bank. "It was an expected increase and a very balanced statement, both designed to keep the market confident in the Fed's ability to manage the economy."

With the Fed acting as anticipated, and with no surprises in its accompanying assessment of the economy, the markets could begin a summer rally as second-quarter earnings reports come in next month.

Most investors and analysts believe the Fed's rate hike is the first of many, with another 0.25 percentage point increase possibly coming as early as the next Fed meeting in August. But with rates historically low to begin with, the cost of borrowing will still be very good for corporate America and won't unduly affect earnings.

"We're now in a rising rate environment, and will be for some time. I think the equity markets realize that, and that's already built into the curve," said Josh Feinman, chief economist for Deutche Asset Management. "The question is, do rates go up fast or slow, more or less? It's the trajectory, timing and the ultimate magnitude that we'll have to watch out for."

Feinman said the Fed should be able to keep to its promise of a "measured pace" of rate hikes, just as long as the economy's growth is moderate.

Prior to the announcement, stocks were sluggish as investors hedged their bets against a Fed surprise that never materialized. Investors are now looking ahead to a key jobs report on Friday, as well as July's second quarter earnings reports.

"The anticipation of this rate hike has been far worse than the reality of it," said Brian Bush, director of equity research at Stephens Inc. "I think it's going to be a positive for the market to get past today's announcement so we can start looking at earnings pre-announcements and the underlying economic data."

Bond prices rallied as the Fed's comments soothed fears that recent signs of inflation might force the central bank to be more aggressive in tightening monetary policy. The benchmark 10-year Treasury note rose 24/32 in price to 101-7/32 while its yield fell to a one-month low of 4.59 percent from 4.69 percent late Tuesday.

Expectations of gradual interest-rate hikes also buoyed shares of homebuilders and banks, which usually tend to suffer as higher rates discourage borrowing.

Homebuilder Pulte Homes Inc (PHI) rose $1.75, or 3.5 percent, to $52.03, which rival Toll Brothers (TOL) gained 78 cents or 1.9 percent, to $42.32. The Dow Jones Home Construction index rose 2 percent.

J.P. Morgan Chase (JPM) rose 48 cents, or 1.3 percent, to $38.77, and helped lift the blue-chip Dow. The Philadelphia Stock Exchange's bank index rose 0.4 percent.

In a preview of what the second-quarter results might look like, a number of companies reported better-than-expected earnings late Tuesday and Wednesday before the session.

Cereal and packaged foods producer General Mills Inc. (GSI) gained $1.41 to $47.53 after posting earnings that beat Wall Street expectations by 2 cents per share.

Agriculture and biotech firm Monsanto Co. (MON) posted a 45 percent gain in quarterly earnings, which were 3 cents over analysts' estimates. Monsanto rose $1.30 to $38.50.

Research In Motion Ltd. (RIMM), makers of the popular Blackberry e-mail pager, surged $9.07, or 15 percent, to $68.45 after it beat estimates by 4 cents per share due to better-than-expected gross margins.

Shares of Qualcomm Inc. added to gains after reaching a three-year high in the previous session as some investors reacted to the new high and others were encouraged by phone companies' plans to develop high-speed mobile services. Its shares jumped $1.43, or 2 percent, to $72.98.

Mortgage giant Freddie Mac (FRE) saw its quarterly earnings fall 52 percent from a year ago due to interest rate volatility, but analysts were cheered by the company's ability to manage risk. Freddie Mac gained 11 cents to $63.30.

Trading was active, with about 1.5 billion shares changing hands on the New York Stock Exchange and 1.7 billion shares traded on Nasdaq.

The Russell 2000 index of smaller companies was up 3.68, or 0.6 percent, at 591.51.

Overseas, Japan's Nikkei stock average ended the session flat. In Europe, Britain's FTSE 100 closed down 1.1 percent, France's CAC-40 fell 0.6 percent for the session and Germany's DAX index dropped 0.4 percent.

Reuters and the Associated Press contributed to this report.