Hundreds of protesters thronged the grounds of the presidential palace recently, demanding a better life. Algeria has seen many demonstrations like this one in its tumultuous modern history, but this time something was different: The marchers were the police usually in charge of crowd control.

The unprecedented demonstrations by Algerian police are signs of divisions at the highest level of authority and could presage more unrest, say analysts, even though the government has moved swiftly to meet some of the officers' demands.

The three days of police protests in a country where all demonstrations are banned come at a time when the president's health problems have already set off feuding between the nation's military and political parties.

And the police were not just demanding higher pay and better benefits. They also were making a political demand: the sacking of the presidential appointee who is the nation's police commander.

Oil-rich Algeria has the most powerful military in the region and is a key ally of the U.S. in the fight against terror, but lately there have been concerns over the nation's stability as the president appears increasingly infirm.

Following a stroke in 2013, President Abdelaziz Bouteflika, 77, has been mostly absent from public life aside from brief mumbling appearances on state television.

The police demonstrations began on Oct. 13 in the southern oasis town of Ghardaia, where police units said they were fed up with months of hard duty keeping the peace between warring Berbers and Arabs communities.

The next day the protests spread to Algiers, the capital, with hundreds of riot police marching through downtown and staging a sit-in at the president's office. Local police units joined in, the crowd swelled to at least 1,000, and at one point it tried to force its way into the building.

The demonstrations spread to other major cities across the country and lasted for three days in a nation where officers are the ones who violently disperse any signs of dissent.

Last week, the Algerian government announced it had agreed to accept several of the officers' demands, including higher pay, shorter work hours and privileged access to new housing — but it ignored calls for the head of police to resign.

With the president apparently weak and absent, Algeria's rival military and political factions are competing for influence, said sociologist Nacer Djabi, who described the demonstrations as "very serious."

"This conflict stems from the tensions at the summit of the state and the war of succession to Bouteflika," he said.

While ostensibly a democracy, power in Algeria resides in the hands of military and ruling party figures who agree on how to dole out the country's immense oil and gas wealth.

Demands for increased salaries or new housing are often quickly agreed to in order to keep the peace. But with oil prices dropping to just $85 a barrel and Algeria's reserves dwindling, it is not clear how much longer that policy can be pursued.

The main police grievance is against the country's top police officer, Director General of National Security Abdelghani Hamel, whom they accuse of mismanaging the service.

"That was never even on the table because it goes back to the powers of the president," a high ranking security official said on condition of anonymity because of the sensitivity of the topic.

The protesters also asked to form a labor union, another demand that was not addressed.

"As long as Bouteflika is in power, Hamel will not be touched and a union will never see the light of day," said Khaled Ziari, a former high-ranking police official and now a counter terrorism expert.

He explained that as Bouteflika's appointee, Hamel would never be dismissed by the president, who would fear looking weak or setting a bad precedent.

The authorities also want to maintain military style control of security forces, so the last thing they want would be unions.

Ziari said that for police the problem with Hamel is that he comes from a different service — the gendarmes, a kind of national paramilitary police — while the police want to be controlled by one of their own.

"The police don't want a gendarme, a soldier or a stranger at their head," said Ziari. "Hamel put many gendarmes into top posts, while there are plenty among the police with the experience to fill these positions."

Ziari warned that ignoring these demands could only increase police bitterness.

Part of the problem is just how much the police are being used these days, said retired army Col. Ahmed Adhimi, who now teaches political science at Algiers University.

According to official figures, the riot police have been used more than 10,000 times since 2012 to deal with an almost constant stream of local demonstrations demanding more government funding or better services.

"In my opinion, the police are tired and fed up with the situation," Adhimi said, describing the crisis as evidence of a lack of civil society, real political leaders and of democracy in general.

"How long can we continue to mobilize the police and gendarmes to keep the calm?" he asked.