Updated

Central African Republic President Francois Bozize and the rebels who sought to overthrow him have reached a deal to create a coalition government with the country's political opposition, an agreement that will allow Bozize to stay in office until 2016, officials said Friday.

The announcement came after several days of talks in Gabon, which were organized after an alliance of rebels groups swept through the north of country seizing control of a dozen towns.

Bozize publicly shook hands with the rebel representatives and other political opponents.

Friday's agreement includes a provision that a prime minister will be appointed from the country's political opposition, and legislative elections will be organized in a year, said Chadian Foreign Affairs Minister Moussa Faki Mahamat.

"The mandate of President Bozize is a constitutional question. We cannot challenge the Central African Republic's constitution," said Chadian President Idriss Deby, who presided over the closing ceremony for the talks.

Bozize seized power in 2003 after a rebellion, and later went on to win elections in 2005 and 2011, though the United States and others have described the votes as deeply flawed.

The rebels, who began their offensive on Dec. 10, had previously called for Bozize to step down from power and had dismissed his calls to form a national unity government. Their offensive stopped short of the capital of Bangui but posed the gravest threat to Bozize during his nearly 10 years in power.