Washington is considering direct talks with Iran on the security situation in Iraq, a US official has told the BBC.

The move comes as US President Barack Obama weighs up options on action to take in Iraq.

Meanwhile, the US condemned as "horrifying" photos posted online by Sunni militants that appear to show fighters massacring Iraqi soldiers.

In the scenes, the soldiers are shown being led away and lying in trenches before and after their "execution".

The Iraqi military said the pictures were real, but their authenticity has not been independently confirmed.

The BBC's Jim Muir, in northern Iraq, says if the photographs are genuine, it would be by far the biggest single atrocity since the time of the American-led invasion of Iraq in 2003.

Their emergence came as the Iraqi government claimed to have "regained the initiative" against an offensive by Sunni rebels led by ISIS - the Islamic State in Iraq and the Levant.

Extremists captured key cities, including Mosul and Tikrit, last week, but several towns have now been retaken from the rebels.

However the insurgents captured the northern city of Tal Afar, west of Mosul, overnight after a heavy mortar bombardment.

Please turn on JavaScript. Media requires JavaScript to play.

The images appear to show captured Iraqi soldiers in civilian clothes being led away by militants, as the BBC's John Simpson reports

Vienna talks

While the US and Iran are old adversaries, both have an interest in curbing the growing threat posed by ISIS and both are considering military support to the Iraqi government, says the BBC's Rajini Vaidyanathan in Washington.

The US is said to be considering direct discussions with Tehran which could even take place as early as this week.

The two countries are due to hold the latest round of talks on Iran's nuclear programme in Vienna.

Iranian President Hassan Rouhani has said he will consider co-operation if the US takes action in Iraq.

The USS George HW Bush aircraft carrier is already being deployed to the Gulf, accompanied by two more warships. But Washington says no US troops will be deployed on the ground.

The US has also announced it is increasing security at its embassy in Baghdad and relocating some staff to safer areas.

Meanwhile, there are reports that more than 130 Iranian Revolutionary Guards are in Iraq to provide training and advice.

The pictures have not been independently verified, but military sources said they were authentic

Taken in trucks

The massacre pictures, apparently posted by ISIS, are said to show what happened to soldiers after the group took over an army base in Tikrit.

Video footage, apparently filmed earlier, shows many hundreds of men being marched off, with the voice on tape saying they had surrendered at the Speicher base.

Still photographs show large numbers of young men being transported away in trucks.

Captions on the photographs, which again appeared to have been issued by ISIS, said they were being taken away to their deaths.

What appear to be ISIS fighters are seen firing on their captives in some images.

Please turn on JavaScript. Media requires JavaScript to play.

The insurgency is increasingly splitting communities along sectarian lines, as the BBC's Paul Wood reports

Sources in the rebel movement, who do not belong to ISIS, told the BBC they believed as many as 1,000 personnel from the base had been executed.

They said the ISIS fighters had divided them into regular army conscripts, who were set free, and volunteers from Shia militias or from the government's elite Golden Brigade, who were condemned to die.

Earlier, Iraqi army spokesman Lt Gen Qasim Ata said the military had scored successes against the militants in several areas, killing 279 of them. The figure could not be independently verified.

Government forces were reported to be building up in the city of Samarra, north of Baghdad, ready for a counter-offensive on Tikrit.

There are reports that thousands of men have joined Shia militias

ISIS in Iraq

The Islamic State in Iraq and the Levant (ISIS) has 3,000 to 5,000 fighters, and grew out of an al-Qaeda-linked organisation in Iraq

Joined in its offensives by other Sunni militant groups, including Saddam-era officers and soldiers, and disaffected Sunni tribal fighters

ISIS has exploited the standoff between the Iraqi government and the minority Sunni Arab community, which complains that Shia Prime Minister Nouri Maliki is monopolising power

The organisation is led by Abu Bakr al-Baghdadi, an obscure figure regarded as a battlefield commander and tactician

Are you in Saadiya, Jalawla or Baghdad? Have you been affected by the latest developments? You can email haveyoursay@bbc.co.uk using the title 'Iraq'.

If you are happy to be contacted by a BBC journalist please leave a telephone number that we can contact you on. In some cases a selection of your comments will be published, displaying your name as you provide it and location, unless you state otherwise. Your contact details will never be published. When sending us pictures, video or eyewitness accounts at no time should you endanger yourself or others, take any unnecessary risks or infringe any laws. Please ensure you have read the terms and conditions.

BBC links

This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.