(Adds detail, context)
By Kamal Naama
RAMADI, Iraq, June 7 (Reuters) - Gunmen occupied a university in Iraq's western Anbar province on Saturday, taking hundreds of students and their professors hostage on campus, security sources said, in the third attack this week by militants who overran parts of two other cities.
After fighting their way past guards overnight, the gunmen broke into Anbar University in the provincial capital Ramadi, parts of which have been held by anti-government tribesmen and insurgents since the start of the year.
Security forces surrounded the university in Ramadi on Saturday and exchanged fire with the militants, who had planted bombs behind them and were patrolling the rooftops with sniper rifles.
Sources in Ramadi hospital said they had received the bodies of two people, one of them a student and the other a policeman.
A professor trapped inside the physics department said some staff who live outside Ramadi had been spending the night at the university because it was the exam period.
"We heard intense gunfire at about 4 am. We thought it was the security forces coming to protect us but were surprised to see they were gunmen," he told Reuters via telephone. "They forced us to go inside the rooms and now we cannot leave".
He was later able to escape along with 15 colleagues and pupils. "I brought some of my students' exam papers in a nylon bag and, wearing my tie and suit, jumped the fence and am outside now," he said.
The militants allowed between 100 and 150 other people to leave the campus, said sources.
The identity of the assailants was not clear, but Ramadi is one of two cities in Anbar that were overrun at the start of the year by tribal and Sunni insurgents, including the Islamic State in Iraq and the Levant (ISIL).
Security forces are in control of central Ramadi, but the suburbs and outlying areas have swung back and forth between them and the militants. The city of Falluja around 50km (31 miles) away is still in insurgent hands.
One of the guards at the university said he believed the militants' real aim was to seize an area called Humaira behind the campus, which would allow them to set up supply lines between Ramadi and Falluja.
"I think the militants will withdraw as their target was not the university. They came to stay in Humaira, and we know how important it is for them," he said.
"They want to be connected with their gunmen in Falluja. I think the security forces realise that."
Almost 480,000 people have been forced to leave their homes in Anbar over the past six months, according to the United Nations, in what is Iraq's largest displacement since the sectarian bloodletting that climaxed in 2006-07.
Violence is still well below those levels, but insurgents have been regaining ground and momentum over the past year, making 2013 Iraq's deadliest year since security began to improve.
Nearly 800 people were killed across the country in May alone - the highest monthly toll this year so far.
On Thursday, militants moved into the city of Samarra in the adjacent province of Salahuddin and briefly occupied a university there as well as two mosques, raising ISIL's black banner until being forced to retreat under airstrikes.
The following day, insurgents fought Iraqi security forces in the northern city of Mosul.
A source at Mosul morgue said the bodies of 70 people had been brought in on Saturday, adding there were still corpses on the streets but they could not be recovered yet some districts of the city remained under militant control. (Additional reporting by Raheem Salman in Baghdad and Ziad al-Sinjary in Mosul; Writing by Isabel Coles; Editing by Sophie Hares)