Zimbabwe's opposition leader, Morgan Tsvangirai, says immediate talks with President Robert Mugabe on ending the crisis over the disputed presidential election must succeed.
The agreement requires talks on a power-sharing arrangement to be completed within two weeks and calls for the prevention of violence.
Mr Mugabe and Mr Tsvangirai shook hands after signing the agreement in the presence of South African President Thabo Mbeki, who acted as mediator.
Mr Tsvangirai described his first meeting with Mr Mugabe in 10 years as historic and said talks must succeed.
United Nations Secretary-General Ban Ki-moon welcomed the deal.
The preliminary agreement was signed in a hotel in Harare after weeks of deadlock. Mr Mugabe was re-elected on 27 June in a one-man election.
Mr Mbeki said the agreement committed both sides to an intense process to try to complete substantive negotiations as quickly as possible.
Mr Tsvangirai called the ceremony "a very historic occasion" and stressed that a solution must be found.
Officials from both sides said the framework agreement sets a two-week deadline for the government and two factions of the opposition MDC to discuss key issues, including a unity government and how to hold new elections.
Mr Mugabe, 84, has ruled for 28 years.