BAGHDAD — The last Iraqi security forces fled Ramadi on Sunday, as the city fell completely to the militants of the Islamic State, who ransacked the provincial military headquarters, seizing a large store of weapons, and killed people loyal to the government, according to security officials and tribal leaders.

The fall of Ramadi, despite intensified American airstrikes in recent weeks in a bid to save the city, represented the biggest victory so far this year for the Islamic State, which has declared a caliphate, or Islamic state, in the vast areas of Syria and Iraq that it controls. The defeat also laid bare the failed strategy of the Iraqi government, which had announced last month a new offensive to retake Anbar Province, a large desert region in the west of which Ramadi is the capital.

“The city has fallen,” said Muhannad Haimour, the spokesman for Anbar’s governor. Mr. Haimour said that at least 500 civilians and security personnel had been killed over the last two days in and around Ramadi, either from fighting or executions. Among the dead, he said, was the 3-year-old daughter of a soldier.

“Men, women, kids and fighters’ bodies are scattered on the ground,” said Sheikh Rafi al-Fahdawi, a tribal leader from Ramadi, who was in Baghdad on Sunday and whose men had been resisting the Islamic State, also known as ISIS or ISIL.