* Premier seeking Sunni, Kurdish support to fight Islamic State
* Jihadists stone man to death for adultery - witnesses
* Iraqi government, Kurdish forces battle militants
* Islamic State will remain threat with Syrian havens - U.S.
* Baghdad offers to release Saddam minister - newspaper
By Raheem Salman and Alexander Dziadosz
BAGHDAD, Aug 22 (Reuters) - Iraqi Shi'ite militiamen opened fire on minority Sunni Muslims in a mosque on Friday, killing dozens just as Baghdad is trying to build a cross-community government to fight Sunni Islamists whose rise has alarmed Western powers.
One Iraqi security source said 30 people had been killed when the militias attacked the mosque in Baquba, capital of Diyala province northeast of Baghdad, on the Muslim day of prayer. Some witnesses put the death toll higher.
The bloodbath marks a setback for Prime Minister-designate Haider al-Abadi, from the majority Shi'ite community, who is seeking support from Sunnis and ethnic Kurds to take on the Islamic State insurgency that is threatening to tear Iraq apart.
In the northern city of Mosul, Islamic State stoned a man to death, witnesses said, as the United States raised the prospect of tackling jihadist safe havens across the border in Syria.
In a regional conflict which is throwing up dilemmas for governments from Washington to London to Baghdad and Tehran, any U.S. action against Islamic State in Syria would risk making common cause with President Bashar al-Assad - the man it has wanted overthrown in a three-year uprising.
Islamic State, which this week released a video showing the beheading of American journalist James Foley, stoned the man to death in Mosul after one of its self-appointed courts sentenced him for adultery, the witnesses said.
The stoning, which happened on Thursday, was the first known instance of the punishment by Islamic State militants in Iraq since it seized large areas of the country in a June offensive. Having poured in from Syria across a desert border that it does not recognised, the movement has declared its own caliphate.
Similar stonings by the radical Sunni group have been previously reported in Syria, where it split from al Qaeda. Islamic State is the most powerful rebel group fighting Assad's forces in a civil war which the United Nations said has claimed almost 200,000 lives at the very least.
Iraqi government forces - which at first put up little serious resistance - are starting to fight back.
Along with fighters from the Iraq's Kurdish autonomous region, they tried on Friday to recapture two towns near the Iranian border, security sources said, backed by U.S. airpower and Iraqi fighter planes.
President Barack Obama's decision to authorise air strikes in Iraq for the first time since U.S. troops pulled out in 2011 has helped to slow the militants' offensive. However, America's top soldier acknowledged that the internationally recognised frontier between Iraq and Syria, over which the militants have free passage, no longer meant much in the wider conflict.
General Martin Dempsey, chairman of the Joint Chiefs of Staff, suggested Islamic State would remain a danger until it could no longer count on safe havens in Syria.
"This is an organization that has an apocalyptic, end-of- days strategic vision and which will eventually have to be defeated," he told reporters in Washington on Thursday.
"To your question, can they be defeated without addressing that part of their organisation which resides in Syria? The answer is no. That will have to be addressed on both sides of what is essentially at this point a non-existent border."
Obama came close to ordering air strikes on Syria last year, but they would have been against Assad's forces which are fighting Islamic State in the complex civil war involving a range of factions battling each other.
At least 191,369 people have been killed in the Syrian conflict up to April, more than double the figure documented a year ago and probably still an under-estimate, the United Nations human rights office said on Friday.
Obama had intended to punish Assad for using chemical weapons in the three-year civil war - charges Damascus denied - but the air strikes were cancelled after a Russian-brokered deal under which Syria surrendered its chemical arsenal.
Sources familiar with Syrian government thinking say Assad is wagering that Islamic State's push to reshape the Middle East will eventually force a hostile West to deal with him as the only way to tackle the threat.
Western governments which back the uprising against Assad have dismissed the idea of rapprochement. But if the United States were to attack Islamic State in Syria, it would find itself - however reluctantly - fighting a common enemy with Assad.
HARD DECISIONS FOR BAGHDAD
Iraq also faces some hard decisions. The government has promised to release from prison a former defence minister of ousted president Saddam Hussein, a senior Sunni official said.
In an interview with the London-based Asharq al-Awsat newspaper, Deputy Prime Minister Saleh Mutlaq did not say why the promises to free Sultan Hashem and other Sunni military and political leaders had been made.
Hashem's release could appease the Sunnis who dominated Iraq until a U.S.-led invasion overthrew Saddam in 2003.
But it would mark a major concession by the government led by Shi'ites and probably upset the Kurdish community. Hashem was sentenced to death for a campaign under Saddam that included gassing Kurds in the town of Halabja in 1988.
The conflict may also mean other old enemies working together, albeit with hard bargains being struck. This includes regional Shi'ite power Iran, which has long been at odds with the United States over its nuclear programme.
Foreign Minister Javad Zarif was quoted on Thursday by the state news agency IRNA as saying Tehran was ready to help tackle Islamic State in Iraq, but first wanted progress in negotiations with world powers over the nuclear programme.
However, perhaps reflecting the sensitivity of the issue, IRNA later reported foreign ministry spokeswoman Marzieh Afkham as dismissing "reports by some news agencies about Iran and U.S. cooperation in Iraq".
France, one of the six nations in nuclear talks with Tehran, said this week it wanted Arab states, Iran and the five permanent members of the U.N. Security Council to coordinate a comprehensive response against Islamic State.
The West fears the programme aims to develop a nuclear weapons capability, while Iran insists it is peaceful. (Additional reporting by Michael Georgy in Baghdad, Stephanie Nebehay in Geneva, William Maclean and Michelle Moghtader in Dubai, John Irish in Paris, Julia Edwards, Missy Ryan, Steve Holland and David Alexander in Washington; Writing by David Stamp; Editing by Alastair Macdonald)
Our Standards: The Thomson Reuters Trust Principles.