Egyptian riot police have cordoned off the headquarters of the journalists' union and limited access to the building in an escalating standoff following a raid on the premises and the arrest of two journalists.

Hundreds of journalists rallied on the steps outside the union headquarters on Wednesday, chanting "Journalism is not a crime!" and demanding the dismissal of the country's Interior Minister Magdy Abdel-Ghaffar.

The protests are the latest in a series of demonstrations against the government of President Abdel-Fattah el-Sisi, which has banned virtually all protests and carried out a wide-ranging crackdown on dissent.

Police severely restricted access, banning non-union members from entry, as well as some residents and people who came on work errands to the surrounding area. Foreign journalists were allowed entry only after approval by several levels of officers, up to the rank of general.

At one point, several dozen journalists pushed through a barrier and entered the area, causing a brief moment of chaos. Several held up their union cards, saying that the police would not let them enter despite the membership. The union is now holding a general assembly.

"There are thugs here threatening us, and the police don't want us to enter for the meeting because they know we'll condemn the Interior Ministry," said journalist Ahmed Bakr, who was allowed into the building's street eventually.

READ MORE: Egypt arrests journalists in raid on press syndicate

Several dozen counter-demonstrators and government supporters showed up at either end of the blocked-off street, blasting patriotic songs, chanting "Long live Egypt" and insulting union members, who responded by calling the police "thugs".

Activist sentenced to jail

In a separate development, prominent Egyptian activist and protest organiser Sanaa Seif has been sentenced to six months in prison for "insulting a public official", she wrote in a Facebook post.

The jail term came months after the government pardoned Seif and 99 others, including journalists and activists.

Since Egypt's President Mohammed Morsi was deposed in 2013, the government of army chief-turned-president Sisi has clamped down on political demonstrations, mainly by opponents demanding Morsi's return.

Hundreds of protesters have been killed and thousands detained over the past three years, and an anti-protest law has virtually banned all street demonstrations without prior police permission.

The two journalists were arrested on Sunday over allegations that they called for anti-government protests following Sisi's recent decision to transfer two Red Sea islands to Saudi Arabia. Egypt's prosecutor general has since defended the raid and imposed a media gag order on the investigation.

Similar blockades at the union headquarters have been imposed intermittently since April 25, when security forces largely quashed demonstrations against the transfer of the two islands. That decision brought protesters on to the streets on two occasions last month, in the largest show of public defiance of Sisi since he was elected in 2014.

"We are here today to defend journalism," said Yahia Kalash, the head of journalists' union, who was at the rally on Wednesday. "We are defending the rights and the dignity of journalists."

Mubarak's PM acquitted

Also in Egypt, a top appeals court has acquitted the ex-prime minister Ahmed Nazif, who had been part of the administration of ousted President Hosni Mubarak, of corruption charges after overturning his sentence for illegal profiteering, his lawyer and a judicial official said.

Nazif had been found guilty by two criminal courts in 2012 and 2015 of illegally amassing $7.2m serving under the former president.

He was sentenced to three years in prison in the first trial, and to five years in the second one.

Both rulings were cancelled by the Court of Cassation.

Nazif was also acquitted of corruption charges in a separate case in February last year, after a criminal court had sentenced him to seven years in prison for his alleged role in awarding contracts for new vehicle licence plates.

Most have since been acquitted.

Those released include Mubarak's sons, who were convicted with their father of stealing from public funds. The sons were freed in October for time served.

Courts also acquitted senior Interior Ministry officials over the killing of hundreds of protesters during the 2011 uprising.