* Iraqi forces take Kurdish-held oil city of Kirkuk
* U.S.-Iran tension helps raise global risk premium for oil
* BoAML sees sizeable deficit on strong demand, tight supply (Updates prices in paragraph 3)
LONDON, Oct 17 (Reuters) - Oil prices firmed on Tuesday, building on gains made as fighting between Iraqi and Kurdish forces threatened supplies from northern Iraq while tension rose between the United States and Iran.
After months of rangebound trading, during which OPEC-led supply cuts supported crude but rising U.S. output capped markets, prices have made significant gains this month.
Brent crude gained 15 cents to $57.97 a barrel by 1320 GMT, up by about a third from its mid-year levels. U.S. light crude was up 5 cents at $51.92.
The Baghdad government recaptured territory across northern Iraq from Kurds on Tuesday, widening a campaign that has shifted the balance of power in the country.
The fighting in one of Iraq's main oil-producing areas helped to restore a risk premium on oil prices, though officials said that oilfields in the region were operating normally.
"The latest bout of geopolitical premium to strike the energy complex remains alive and well as oil prices build on recent gains," said Stephen Brennock, analyst at London brokerage PVM Oil Associates.
Goldman Sachs said the Kirkuk cluster of oilfields, which pump about 500,000 barrels per day (bpd) and extend from the autonomous Kurdistan region into northern Iraq, were at risk from the conflict.
Tension between the United States and Iran is also rising, increasing the global risk premium for oil.
U.S. President Donald Trump on Friday refused to certify Iran's compliance over a nuclear deal, leaving Congress 60 days to decide on further action against Tehran.
During the previous round of sanctions against Iran, about 1 million bpd of oil was cut from global markets.
"Oil and geopolitics are very much interlinked," Fatih Birol, executive director of the International Energy Agency, told Reuters. "Oil security remains a critical issue."
With supply cuts led by the Organization of the Petroleum Exporting Countries tightening the market, analysts have been raising their oil price forecasts.
Birol said the rate of compliance by OPEC and its partners in their targeted cutting of about 1.8 million bpd between January this year and March 2018 was about 86 percent.
Bank of America Merrill Lynch said it was raising its oil price forecasts.
"We see Brent averaging $54 this quarter and $52.50 per barrel in 1H18, compared with our previous forecasts of $50 and $49.50 per barrel respectively," it said. (Additional reporting by Henning Gloystein in Singapore; Editing by David Goodman and Louise Heavens)