ALGIERS When Moncef Marzouki, a former dissident transformed by the "Arab Spring" into Tunisia's president, paid an official visit to Algeria on Sunday, red and white Tunisian flags flew from lamp-posts in his honor.
Just two days earlier, another former dissident and leading figure of Tunisia's revolution had been barred from entering. Sihem Bensedrine was allowed into the country after a seven-hour wait only after protests from fellow human rights activists.
The "Arab Spring" is knocking on Algeria's door, but the authorities cannot decide whether to let it in or shut it out.
Bensedrine, for one, believes the choice has been made.
"I think the Tunisian revolution is not particularly welcome," Bensedrine told Reuters in the capital, Algiers.
Alone among its neighbors in North Africa, Algeria has been largely untouched by the uprisings which last year ousted leaders in Tunisia, Egypt, Libya and Yemen and touched off the revolt still raging in Syria.
Helped by revenues from energy exports that have bequeathed it the world's 14th biggest foreign exchange reserves, the Algerian authorities handed out pay rises, grants and subsidies that blunted a brief flare-up of protests demanding reform.
The country's rulers continue to run the country much as they have since independence from France 50 years ago: with a huge state apparatus backed by the powerful security forces and elections dominated by the ruling FLN party and its allies.
That is looking more and more out of step with the mood of the times, however, and a parliamentary election set for May 10 could be a watershed.
Pressure is building inside Algeria and abroad to ensure a fair election. As elsewhere in the Middle East, it is likely to give greater power to Islamists who for years have been pushed to the fringes by the strongly secularist state.
"People expect Algeria to come into line with the region," said a diplomat based in Algiers. "There's an expectation that Islamists will have greater influence."
Most independent observers predict that the ruling establishment will adapt to the new circumstances in the same way it has for decades when its hold on power has been challenged.
Algeria will probably follow the model of neighboring Morocco, the observers say. There, the ruling elite conceded to pressure by allowing a moderate Islamist opposition party to head a new government, but kept the levers of real power in its hands.
Western powers favour this scenario. They depend on the help of Algeria, the biggest military power in the region, to contain the spreading threat from al Qaeda's north African wing around the southern edge of the Saharan desert.
They also fear that any turmoil could disrupt the flow of natural gas through pipelines under the Mediterranean Sea. Algeria supplies about one fifth of Europe's gas imports.
One factor that could derail this managed transition to limited democracy is Algeria's bloody history: after the military-backed government annulled a democratic election in 1992 fearing an Islamist takeover, security forces and Islamists fought a war that killed an estimated 200,000 people.
The shadow of the conflict still hangs over the country. In the Chifa mountain gorge, once a favorite picnic spot an hour's drive south of Algiers, security forces have posts on top of almost every ridge, where they hunker down behind concrete, sandbags and razor wire.
The insurgency, now affiliated to al Qaeda, has lost momentum but still carries out sporadic kidnappings, ambushes and suicide bombings - a young soldier died this month after stepping on an improvised explosive device.
Few expect a return to the "black years" as they are known in Algeria; the Islamists are much weaker now while the state is richer and stronger. But it is unclear how security forces will react if Islamists muster huge support in the election and demand a share of real power.
"An Islamist majority in parliament ... would probably trigger a reaction from the military elite," said Riccardo Fabiani, North Africa analyst with Eurasia Group. "The strongly secular security forces are ready to intervene to guarantee their vested interests."
Commentators say there are divisions inside the ruling elite.
One camp believes the pragmatic thing to do is to allow more democracy. President Abdelaziz Bouteflika has said the authorities should not manipulate the upcoming election as they have done in the past.
Nearly 20 new parties have been given the green light to compete, including at least one which represents a serious challenge to the establishment.
A commission of judges will oversee the vote count, replacing the interior ministry officials who usually do the job. The European Union has been invited to send observers for the first time.
There are subtle signs that a nervous security apparatus is tightening control over dissent, however.
Mourad Dhina, an Algerian scientist who used to work at the CERN physics research institute in his adopted home of Switzerland, was arrested last month in Paris after attending a meeting of Rachad, an Algerian Islamist opposition movement whose leaders are based mostly in Europe.
He is now in La Sante prison awaiting a hearing to decide if he will be extradited to Algeria, where a court in 2003 found him guilty of having links to armed Islamist groups.
Michael Romig, a spokesman for the Al Karama human rights organization which Dhina headed up, said it was odd that he had been arrested now. Dhina had lived openly in Switzerland for years and travelled often to France.
"We are as confused as everyone," Romig said.
However, Rachad, of which Dhina is a founder, had in the past few months launched a London-based satellite television station broadcasting into Algerian homes, and placed links on one of its Internet sites on "how to free your country" and "organize and participate in unrest."
Many Algerians do not think the parliamentary election in May will provide the spark that sets off an upheaval.
Parliament has limited powers under the constitution, they say, and anyway, most people are apathetic about a political system that they do not feel has any relevance to their lives.
Much of the discontent has been contained by the authorities' spending spree. In one example, thousands of young unemployed people have been taken on the payroll at state-owned firms, even when there is no work for them to do.
"I get 15,000 dinars ($200) to do nothing," said Ahmed Selmi, 27, from Haizar, a village about 150 km (95 miles) southeast of the capital, who is employed at a state company but was out drinking coffee with friends at 11 a.m.
"I have no task to do there," he said.
Ahmed Benbitour, prime minister of Algeria at the end of the 1990s, said all the state had done with its largesse was to buy itself a temporary reprieve.
"We're a long way from having bought social peace," he told Reuters. "All we are doing is putting out fires.
"The conditions which prevailed for the Arab Spring are present in all Arab countries. There are no theoretical reasons why one country should be able to escape this movement."
The strongest evidence for this argument is in the almost daily protests, strikes and riots that show no sign of abating.
A week-long period provides a snapshot.
On January 31, riot police in a suburb of Algiers battled petrol-bomb-throwing residents who accused the authorities of failing to investigate the murder of a young man. A day later, in Tiaret, 250 km west of Algiers, 30 people were injured and buildings ransacked after a local man set himself on fire.
On February 5, residents burned down the local government headquarters in a village near Boumerdes, east of the capital, because heavy snow left them with no electricity.
The protests have not come together into any kind of national movement, and the protesters do not appear to have a political agenda beyond railing against local bureaucrats.
But Abdou Bendjoudi, a 27-year-old opposition activist in the capital, thinks it is just a matter of time before that changes and Algeria stages its own "Arab Spring".
He says people have lost faith in a government that has failed to provide real jobs and opportunities for young people or to deliver decent public services.
"There is not a single province where there are not daily protests," Bendjoudi, one of the leaders of a group called the Movement of Independent Youth for Change, said in a cafe. "It is a political message. People are saying they have had enough of the catastrophic management of the country.
"If the authorities do not move now towards democracy, it will be too late."
(Editing by Sonya Hepinstall)