* Ramadi tribes turn on al Qaeda fighters
* Anbar violence is test of strength for Maliki
* Syria war feeding instability in Iraq
By Suadad al-Salhy
BAGHDAD, Jan 3 (Reuters) - Sunni Muslim tribesmen backed by Iraqi troops fought al Qaeda-linked militants for control of Iraq's western province of Anbar on Friday in a critical test of strength for the Shi'ite-led government of Prime Minister Nuri al-Maliki.
Dressed in black and waving al Qaeda flags, hundreds of Islamist insurgents using machine guns and pick-up trucks mounted with anti-aircraft guns battled tribesmen in the streets of the city of Ramadi on Friday, witnesses, security officials and tribal sources said.
The deployment of tribesmen against the militants -- fellow Sunnis -- was made possible by a deal tribal leaders struck with the Baghdad government late on Thursday to counter al Qaeda, which has seized government and police buildings in Ramadi and the province's other main city Falluja, tribal leaders told Reuters on Friday.
Al Qaeda's Islamic State of Iraq and the Levant (ISIL) has been tightening its grip in Anbar, a Sunni-dominated province near the Syrian border, in recent months in a bid to create an Islamic state across the Iraqi-Syrian border.
"There is no way to let al Qaeda keep any foothold in Anbar," said one tribal leader, who asked not to be named. "The battle is fierce and not easy because they are hiding inside residential areas."
The army, which had withdrawn from Anbar on Monday, has been deployed on the outskirts of Ramadi and Falluja to back the tribesmen against al Qaeda, the sources said.
Tension has been high in Anbar, which occupies a third of Iraq's territory, since police broke up a Sunni protest camp on Monday. At least 13 people were killed in clashes.
The turmoil in Iraq and recent deadly attacks in Lebanon, shows the war in Syria, where mostly Sunni rebels are battling a government backed by Shi'ite power Iran, is feeding sectarian instability across the Middle East.
The deteriorating political climate made many Iraqis fear the country was heading for an explosion of Shi'ite-on-Sunni bloodshed that would fracture it along sectarian lines.
Those fears were stirred anew on Thursday when tribesmen, angry at the central government in Baghdad and what they perceive as Sunni marginalisation in politics, clashed with Iraqi troops trying to regain control of Falluja and Ramadi.
But the late Thursday agreement between the tribes and the government appeared to complicate the odds for Islamist militants seeking to establish local control.
"Those people are criminals who want to take over the city and kill the community," said Sheikh Rafe'a Abdulkareem Albu Fahad, leading the tribal fight against al-Qaeda militants in Ramadi.
In Falluja, Islamist militants grabbed loudspeakers after Friday's prayers to call on worshippers to support them in their struggle, eyewinesses said.
There were no clashes between tribesmen and militants in Falluja, the witnesses said, but masked insurgents have control over large parts of the city and have set up several checkpoints in the city.
The late Thursday agreement, if it holds, is likely to draw comparisons to a decision by local tribes in 2006 to join forces with U.S. troops and rise up against al Qaeda forces who seized control of most of Iraq's Sunni areas after the 2003 U.S. invasion.
American troops and local tribes finally beat al Qaeda back in heavy fighting after a "surge" of U.S. forces in 2006-07.
Today the jihadists once again aim to control towns and cities and realise their dream of a state ruled according to strict medieval Sunni Islamic practice.
They have joined forces with powerful groups fighting in neighbouring Syria against Assad, and aim to establish a Caliphate that would transcend modern state borders.
(Reporting by Suadad al-Salhy, Writing by Rania El Gamal, Editing by William Maclean and Philippa Fletcher)