We develop a model for high-Tc superconductors based on an electronic phase separation where low-and high-density domains are formed. At low temperatures this system may act as a granular superconductor forming an array of Josephson junctions. Cuprates are also known to have low superfluid densities and strong correlation effects. Both characteristics activate a negative Josephson coupling due to frustration that leads to spontaneous currents responsible for the weak ferromagnetic order. This original approach reproduces the observed onset of spontaneous magnetic signal and its dependence on the doping level.