CAIRO, March 4 (Reuters) - An Egyptian court on Tuesday banned all Hamas activities in Egypt in another sign that the military-backed government aims to squeeze the Palestinian Islamist group that rules the neighbouring Gaza Strip.

Hamas is an offshoot of Egypt's Muslim Brotherhood, which the authorities have declared a terrorist group and which they have repressed systematically since the army ousted one of its leaders, Mohamed Mursi, from the presidency in July.

"The court has ordered the banning of Hamas's work and activities in Egypt," the judge, who asked not to be named, told Reuters.

During his year in power, Mursi gave red-carpet treatment to Hamas, angering many secular and liberal Egyptians who saw this as part of a creeping Islamist takeover following the 2011 uprising that toppled autocrat Hosni Mubarak.

The military-buttressed authorities now classify Hamas as a significant security risk, accusing it of supporting an Islamist insurgency that has spread quickly since Mursi's fall, allegations the Palestinian group denies.

Security officials said in January that after crushing the Brotherhood, military rulers planned steps to undermine Hamas.

The court also ordered the closure of Hamas offices in Egypt, one of the judges overseeing the case told Reuters. The judge stopped short of declaring Hamas a terrorist group, saying the court did not have the jurisdiction to do so.

Hamas condemned the ruling.

"The decision harms the image of Egypt and its role towards the Palestinian cause. It reflects a form of standing against Palestinian resistance (to Israel)," said Sami Abu Zuhri, a spokesman for the Gaza-based militant organisation.

During Mursi's rule, Hamas held secretive internal elections in Egypt in 2012. A top Hamas official, Musa Abu Marzouk, lives in Cairo and may be at risk of arrest after the court decision.

The case against Hamas was filed after Mursi's removal by a group of Egyptian lawyers who asked for it to be outlawed in Egypt and designated a terrorist organisation.

ISLAMIST INSURGENCY SPREADING

Islamist militants based in Egypt's Sinai region, which has a border with Gaza, have killed hundreds of police and soldiers since Mursi's political demise. The insurgency has spread to other parts of Egypt, the most populous Arab country.

Since seizing power, Egypt's military has crippled Gaza's economy by destroying most of the 1,200 tunnels that had been used to smuggle food, cars and weapons to the coastal enclave, which is under an Israeli blockade.

Egyptian officials say it could take years to undermine Hamas. But they believe working with Hamas's main Palestinian political rival, the Western-backed Fatah movement, and supporting popular anti-Hamas activities in Gaza will weaken the group, several security and diplomatic officials have said.

In early January, Cairo publicly hosted the first conference of a new anti-Hamas youth group called Tamarud (Rebellion), the name used by the Egyptian youth movement behind last year's mass protests against Mursi, Egypt's first freely elected leader.

Hamas seized the Gaza Strip in 2007 after a brief civil war with Fatah, which is led by Palestinian President Mahmoud Abbas.

Both the Muslim Brotherhood and Hamas deny accusations of terrorism, and the Brotherhood says it remains committed to peaceful activism despite Cairo's security clampdown.

Egypt has arrested almost all the Brotherhood's leaders and thousands of its followers, while security forces have killed hundreds of pro-Mursi demonstrators in the streets.

The wave of detentions has also netted some secular protesters, some of whom have alleged torture while in custody.

An Egyptian court on Tuesday released two such activists held on charges of "incitement to protest without a permit" based on a strict new law against demonstrations, saying there was insufficient evidence to keep them jailed pending their case.

Mursi is on trial facing multiple charges, including inciting the murder of protesters during his presidency and collaborating with Hamas to stage terrorist attacks in Egypt. He denies the charges and accuses the army of staging a coup. (Additional reporting by Nidal Al Mughrabi in Gaza and Noah Browning in Cairo; Writing by Michael Georgy; Editing by Mark Heinrich and Alistair Lyon)