* Brent crude prices climb back above $40
* World stock markets edge up, following oil
* Focus shifting to Thursday's ECB meeting (Adds close of European bond, stock markets; oil settlement)
By Caroline Valetkevitch
NEW YORK, March 9 (Reuters) - Oil prices resumed a month-long rally on Wednesday, helping to lift world stock markets, while bond prices weakened ahead of this week's European Central Bank meeting.
Brent moved back above $40 a barrel on speculation the world's largest exporters would agree this month to freeze production and help reduce the largest global build in crude oil in years.
Brent rose $1.42 to settle at $41.07 a barrel, while U.S. crude rose $1.79 to settle at $38.29.
U.S. stocks were moderately higher, with gains in the S&P 500 led by a 1.7 percent jump in the S&P energy index.
The Dow Jones industrial average rose 26.2 points, or 0.15 percent, to 16,990.3. The S&P 500 gained 7.98 points, or 0.4 percent, to 1,987.24 and the Nasdaq Composite added 19.90 points, or 0.43 percent, to 4,668.73.
MSCI's all-country world stock index gained 0.21 percent, while in Europe, the pan-regional FTSEurofirst 300 index closed 0.45 percent higher.
The biggest weekly draw in U.S. gasoline in almost two years persuaded traders that energy demand was improving despite crude stockpiles at record highs.
The U.S. Energy Information Administration said stockpiles rose 3.9 million barrels to nearly 522 million barrels, as predicted by analysts in a Reuters poll.
But gasoline inventories fell 4.5 million barrels, much more than the polled number of 1.4 million barrels.
"Gasoline is the star of the show today," said Matt Smith, director of commodity research at New York-based energy data provider ClipperData. "Ongoing strength in demand has yielded a large draw to gasoline inventories despite a rebound in refinery runs."
Traders expect the ECB on Thursday to cut its deposit rate by at least 10 basis points and expand its asset-buying program.
In the bond market, prices of safe-haven government bonds in the United States and Europe dipped ahead of the ECB meeting.
The benchmark 10-year note was last down 16/32 in price to yield 1.8900 percent.
With so much priced in, however, some investors are primed for a repeat of the sharp gains in the euro seen in December when the ECB's measures fell short of market expectations.
The euro fell slightly against the dollar at $1.1000. (Additional reporting by Abhiram Nandakumar in Bengaluru; and by Dhara Ranasinghe, Anirban Nag and Amanda Cooper in London; Editing by Nick Zieminski and Meredith Mazzilli)