Oil prices rose 2.5 percent on Friday, staging their first weekly gain in a month, after U.S. housing data sparked optimism that a battered sector of the economy may be primed for recovery.

Oil rose for a fifth day and gained 6.1 percent on the week, partially reversing its 10 percent plunge last week.

A government report Friday showed construction of new homes and building permits in the United States rose more than expected in June, signaling a potential economic recovery.

The housing data added further support to oil prices after better-than-expected U.S. corporate earnings and robust Chinese economic growth figures this week.

Renewed violent protests over the contested presidential election in crude supplier Iran on Friday, and a tropical wave in the Central Atlantic that posed a threat of developing into a tropical storm, also spurred oil buying ahead of the weekend.

Oil is rebounding because there's a sense we have probably overplayed pessimism about the economy lately, and prices had fallen too far, said Phil Flynn, an analyst at PFGBest Research in Chicago.

Increased tension in Iran and a tropical wave (in the Atlantic) are also considerations. People don't want to be caught short over the weekend.

U.S. crude oil for August delivery settled up $1.54 at $63.56 a barrel by 2:10 p.m. EDT. London Brent crude for September rose $1.63 to settle at $65.38 a barrel.

In OPEC oil producer Indonesia, bombs ripped through two luxury hotels in capital Jakarta, killing eight and wounding dozens in coordinated attacks.

Oil rose in spite of a 0.3 percent strengthening of the U.S. dollar against a basket of foreign currencies. A strengthening dollar often weakens oil prices, which had fallen in earlier trade, as it makes crude more expensive in most regions.

Global stocks rose on Friday and touched a one-month high in earlier trade. Bank of America posted lower earnings but Citibank rose after a one-time gain to return a profit, following strong profits from banking peers this week, which pushed equities higher.

In China, refiners in the world's No. 2 energy consumer boosted production by 6 percent in June to a record high, after a rise in domestic motor fuel prices aided margins, although higher inventories and rising exports suggested domestic demand was lagging.

Data earlier this week showed Chinese economic growth sped up to hit 7.9 percent in the second quarter, fueled by state spending and bank lending.

Oil prices are down more than $6 a barrel since early July, partly reversing last quarter's 40 percent surge, on concerns over energy demand. In the United States, distillate inventories hit a fresh 25-year high last week, while refiners have been running at lower-than-normal rates for the summer season.

(Additional reporting by Christopher Johnson in London, Robert Gibbons in New York and Fayen Wong in Perth; Editing by Walter Bagley)