SANAA (Reuters) - The Yemeni government and northern Shi'ite rebels agreed on Thursday to a truce aimed at ending a war that has raged sporadically since 2004 and drawn in neighboring Saudi Arabia, both sides said.
A ceasefire was to begin at midnight (2100 GMT).
The Yemeni government, simultaneously battling a resurgent al Qaeda and southern separatists in addition to the northern insurgents, had been exchanging proposals with the Shi'ite rebels for several days to end the conflict.
"We decided to stop military operations in the northwest region starting from midnight tonight," a government statement broadcast on state media said.
"That is to stop the bloodshed and bring peace to the northwest region and to return the displaced to their villages," it added.
The leader of the rebels, who complain of social, religious and economic discrimination, also ordered his fighters to abide by the ceasefire.
"According to what was agreed upon, Abdel-Malik Badreddin al-Houthi issued instructions to all fronts and fighting sites to stop firing coinciding with the timing announced by the government," a rebel statement said.
The turmoil on multiple fronts in Yemen has raised fears in the West and Saudi Arabia that the country may become a failed state, allowing al Qaeda to use it as a base for attacks on the top oil exporter and beyond. A Nigerian accused of trying to blow up a U.S. jet in December had links to Yemen.
One analyst said he was optimistic about the truce holding.
"This looks like a real thing. It has been prepared for weeks. Both sides seem genuinely committed," independent political analyst Abdul-Ghani al-Iryani said.
Riyadh was drawn into the conflict in November when the rebels seized some Saudi territory, complaining that Riyadh was letting Yemeni troops use its land for attacks against them.
Riyadh declared victory over the rebels last month after insurgents offered a separate truce and said they had quit Saudi territory. Rebels say Saudi air strikes have continued.
WILL TRUCE LAST?
Yemeni officials have said that as part of a ceasefire deal, Sanaa would allow rebel representatives to sit on a committee overseeing the truce, and insurgents would hand over weapons they seized from the Yemeni and Saudi forces.
"I am optimistic this time that the Houthis will be committed and the ceasefire will last," a senior Yemeni government official said. The rebels are widely referred to by the family name of their leader.
The conditions demanded of the rebels include opening roads and freeing detained soldiers and civilians, whether Yemeni or Saudi.
Yemen says the rebels must also return captured military and civilian equipment, stay out of local politics and end border hostilities with Saudi Arabia.
The Yemeni government statement said the rebels had agreed to ending attacks on Saudi Arabia, a condition Sanaa added after Riyadh launched an assault against the rebels in November.
One official said President Ali Abdullah Saleh had briefed a committee charged with supervising conditions for a truce on his decision to stop the war, which the United Nations says has displaced 250,000 people.
Yemen state television said the government and rebels had also formed smaller joint committees to supervise the truce in four areas, including on the Yemen-Saudi border.
The committees were to start work on Friday, and one official said they would be flexible on the timeline for truce conditions to be fulfilled.
The rebels said they would start opening the roads and removing checkpoints once the truce stabilized.
The deadline for the full implementation of the truce had been a point of contention, with the rebels asking for more time for their fighters to leave mountainous positions, they said.
Qatar brokered a short-lived ceasefire between the government and rebels in 2007 and a peace deal in 2008, but clashes soon broke out again. Saleh unilaterally declared the war over in July 2008. Full-scale fighting resumed a year later.