The Egyptian government launched an all-out attack on foreign and domestic journalists Thursday, detaining, beating, and harassing those trying to cover the violence unleashed on peaceful democracy protesters.

But the threatening atmosphere has been building for several days leading up to the assaults. The friendly Cairo that I know and am accustomed to working in was transformed into a newly hostile environment beginning Tuesday.

That day, protesters at a massive rally in Tahrir Square against President Hosni Mubarak warned me of reports on Egyptian state television that foreign agents were infiltrating Egypt, posing as journalists.

IN PICTURES: Exclusive Monitor photos of Egypt's turmoil

As I returned home from the protests late that evening, a soldier at an Army checkpoint demanded and pored over the passports of myself and Monitor photographer Ann Hermes. When our driver asked if that was really necessary for two “respectable foreigners,” the soldier raised his eyebrows.

“Yes, it is,” he warned as he leaned closer to the driver and lowered his voice. “They have stopped some foreigners who were taking pictures. They checked their IDs, and they weren’t journalists. It’s very bad.”

The implication was clear: anyone posing as a journalist – without credentials – is a spy. The soldier looked long at our passports, flipping to my visa page before he allowed us to go.

But it wasn’t only the authorities we had to fear. In the security vacuum left when police disappeared from the streets Saturday, residents of Cairo’s neighborhoods armed themselves with clubs, knives, and guns, and set up checkpoints on the roads.

The authority of the gun

At the next checkpoint, manned by one such neighborhood-watch group, a civilian asked again for our passports. When I asked him what authority he had to take my passport, he shifted so that I could see the handgun he held. I handed over the passport.

At another civilian checkpoint, the man who stopped the car by gesturing with his club glanced at us and said to the driver in Arabic, “Don’t trust the foreigners.” Clearly the news circulated by state television had begun to trickle down, though we didn’t realize its reach until Wednesday.

RELATED: Six countries in the Arab world where 'winds of change' are blowing

That morning, we went to a market in the Saad Zaghloul neighborhood. I began my reporting by asking a guava seller about price fluctuations. All was normal. He was friendly, as most Egyptians are, and answered my questions with no problem. But then a woman saw my notebook, looked at my face, and demanded, “Where are from? Why are you here? What are you doing?”

Instantly, a hostile crowd gathered around me, demanding to see proof that I was a journalist and accusing me of being a foreign agent or portraying Egypt in a bad light.

Instant hostility

I had never experienced this kind of hostility in Cairo before. Stunned, I decided to extricate myself from the crowd and try again elsewhere. Again, as soon as I asked a shop owner a question, angry people surrounded me, yelling in my face, some calling me a Jew. Now fearful of my physical safety, I pulled out my press card to try to dispel suspicion. They tried to rip it out of my hands, but it satisfied the crowd enough that I was able to get out, only to find our photographer, Ann, also surrounded by angry people.

As we left the neighborhood, unable to continue our reporting, I could hardly believe what had just happened.

Never, in my three years in Cairo, had I experienced anything like it. But it was nothing compared to what happened when we joined the protests at Tahrir Square.

Violence had broken out suddenly, as thugs and Mubarak supporters attacked the peaceful crowd. We ran to cover the action from the side of the safer, pro-democracy, anti-Mubarak crowd. But when Ann raised her camera to photograph the men throwing rocks, she was an instant magnet for abuse.

Men hit her camera, pushed her, and roughed her up. “No photos!” they shouted threateningly. We tried to leave the men behind, but more like them were everywhere.

When one man grabbed her and tried to drag her off, we struggled with him and Ann's shirt was torn. We were under siege; everywhere we turned, people were threatening us. We saw that other foreign journalists around us, particularly photographers, were also under attack. Some were arrested.

It's one thing to keep an eye out for incoming rocks or tear gas canisters, as I did last week, with a friendly crowd around me, when police fought the protesters. It's another to try to dodge flying chunks of concrete and angry aggressive men at the same time.

We couldn’t tell who the attackers were; we were on the pro-democracy, anti-Mubarak side of the battle line, but there appeared to be at least some government thugs who had infiltrated the crowd.

At least two men shadowed us before starting to feed me pro-Mubarak opinions.

That evening, by the time anti-Mubarak protesters had secured their hold on the square, the atmosphere had changed entirely. Protesters thanked us for being there to document the violence their government had unleashed against them. They encouraged us to take photos. The night-and-day contrast led us to believe that the people who had earlier attacked us were not part of the same crowd.

At an Army checkpoint on the way home in the early hours of the morning, we were stopped and detained for half an hour, without our passports. Our driver was forced to remain behind for extensive questioning about us while the officer in charge forced us to ride the remainder of the way with a man who appeared to be a military police officer. He later returned to my home and questioned my doorman about my work and habits.

Today (Thursday) the situation only worsened: dozens of foreign journalists – along with bloggers, rights activists, and lawyers – have been arrested, beaten, and attacked by police, thugs, and the Army. Egypt’s new vice president, in a televised address, accused foreign elements of infiltrating the protests.

Thursday's incredible crackdown raises the question of what the government has planned for Friday, Islam's holy day and the traditional day for Muslims to gather for prayer – and protests.