Egyptian justice officials and police raided offices of four civil society organizations on Thursday as part of an investigation into foreign funding of such groups in Egypt, a security source said.

The raids targeted local offices of the U.S.-based International Republican Institute and National Democratic Institute (NDI), among others, said the security source and employees at some of the groups.

Security forces who said they were from the public prosecutor are raiding our offices as we speak. They are grabbing all the papers and laptops as well, said one person working at NDI, who gave her name as Rawda.

The security source said employees at the offices were not allowed to leave while the searches continued.

Egypt's military has vowed to investigate how pro-democracy and human rights organizations are funded and has said repeatedly it will not tolerate foreign interference in the country's affairs.

Some Egyptian human rights groups have been at the vanguard of protests demanding that the army, in power since February when President Hosni Mubarak was ousted, hand power swiftly to elected civilians.

Clashes between protesters and soldiers in Cairo this month left 17 people dead.

The army has pledged to step aside by mid-2012.

Political experts said the groups raided on Thursday have taken a neutral political stance, focusing on fostering democracy in Egypt by training members of nascent parties.

The National Democratic Institute has been training new parties ... in how to participate in elections, a leading member of a liberal party said on condition of anonymity.

This has been with the full knowledge of authorities and was not clandestine.

(Reporting by Sherine El Madany, Yasmine Saleh, Marwa Awad and Patrick Werr; Writing by Tom Pfeiffer)