(Adds quote, detail) BUDAPEST, Sept 24 (Reuters) - Hungary's two coalition parties reached a deal on the overhaul of the state health insurance system on Monday, ending months of wrangling and opening the door for further reform in the health sector. "A political agreement has been reached on health insurance," Socialist MP Mihaly Kokeny said, quoted by the national news agency MTI. Health reform is a major part of Hungary's efforts to reduce its budget deficit from over 9 percent of gross domestic product (GDP) last year, the biggest in the European Union, to 3 percent by 2009. The ruling Socialists and their junior coalition partner the Free Democrats had been unable to agree on how the present single state insurer system could be replaced with several insurance funds in which private firms can also buy stakes. The tension over health reform weighed on the parties' relations for months and although it did not pose a risk to the coalition itself, investors holding Hungarian assets wanted to see the reform move ahead. Monday's deal allows the government, which launched tough budget cuts and reforms last year and saw its popularity ratings plunge as a result, to continue health reform. Under the agreement, the present single state insurer system could be replaced with insurance funds in each of 18 counties, while in Budapest and surrounding Pest county, four funds could be set up, MTI reported, citing Kokeny. Private firms can buy stakes in the new funds and the funds will be allowed to seek clients in regions other than their own base county. Hungary's budget deficit is seen falling to 6.4 percent of GDP in 2007 and the health fund, one of the biggest drains on the budget, is heading for its first ever surplus this year due to lower drug subsidies and more people paying contributions. The fund has had an annual deficit each year since 1995.