After the signing, South Africa's intelligence minister scolded a journalist who raised questions about Zimbabwe's record on human rights.
Details of the deal were not released but Zimbabwe's secret police is accused of torturing opposition activists.
South Africa is a key player in attempts to negotiate an end to Zimbabwe's political crisis.
President Thabo Mbeki has been criticised at home and abroad for not putting more pressure on President Robert Mugabe's government to end abuses.
Zimbabwe prayers
"This week's historic meeting further consolidates a long-standing socio-political and economic relationship between our two countries," South African Intelligence Minister Ronnie Kasrils said at the signing of the agreement in Cape Town on Thursday.
After the signing, a journalist asked Mr Kasrils how South Africa, with a "good human rights track record", could sign agreements with Zimbabwe, which had a "poor human rights record".
Mr Kasrils apologised to his Zimbabwean counterpart, Didymus Mutasa, for the question.
"We have very strong ties with our neighbour and we are indebted to our neighbour for achieving freedom and liberty," Mr Kasrils said.
Mr Mutasa suggested praying for the journalist.
"Lord forgive him for he does not know what he is saying," Mr Mutasa said.