"The preliminary detention is legitimate and necessary," the statement of judge Richard Concepcion quoted by the TV Peru broadcaster read.
Humala's house was blocked by police while the court's verdict was announced. The judge has reportedly issued the arrest warrants but it is still unknown, where the former president and his wife will be imprisoned.
Humala is suspected of receiving bribes from construction companies Oderbrecht and OAS, which were used for financing election campaigns of Peruvian Nationalist Party in 2006 and 2011.
The wife of the president is suspected of being involved in money laundering via funds, which sponsored Humala's election campaign.
The news comes against the background of corruption scandal in another Latin American country, Brazil, where OAS was also involved.
On Wednesday, Brazil's former President Luiz Inacio Lula da Silva was found guilty of receiving about $1.2 million worth of bribes from Brazilian OAS construction company, with the money spent on refurbishing a luxury three-story beach apartment in the seaside town of Guaruja. In exchange for bribes, the OAS reportedly was able to get beneficial contracts from the state-owned oil company Petrobras.