Sanaa, Yemen (CNN) -- Yemen's embattled President Ali Abdullah Saleh has accepted a deal brokered by neighboring Persian Gulf nations to step down, Yemeni officials said Saturday.
Both Saleh and the Yemeni opposition have agreed to the deal in principle. But Saleh has yet to sign the agreement, which stipulates he leave office within 30 days and provides complete immunity for him and those who served in his regime, said a senior foreign ministry official, who requested anonymity because he is not authorized to speak to the media.
Mohammed Albasha, spokesman for the Yemeni Embassy in Washington, said the opposition has to accept the final deal before Saleh will sign.
The agreement also calls for a unity government to be formed within seven days.
Yemen's state-run media quoted Deputy Minister of Information Abdu al-Janadi as saying that the political crisis will "have a solution which appeases all parties to take the country to a better democracy."
He told the Saba news agency that Saleh "welcomed the initiative presented by foreign ministers of the Gulf Cooperation Council and showed readiness to positively deal with it according to the Yemeni constitution."
The bloc of six oil-producing Gulf nations, known as the GCC, has been working to ease tensions between Saleh and an increasingly restive opposition.
Previously, Yemen's largest opposition group, the Joint Meeting Parties (JMP) bloc, had objected to the Gulf initiative for failing to state clearly that Saleh must stand down.
Even after agreeing to the deal, Saleh lashed out at the opposition, accusing them of "receiving dirty money to topple the government."
"We are very interested in preventing bloodshed because the Yemeni blood is very precious and the opposition can't drag us to killing each other," Saleh said. "Civil war will not only affect Yemen, but also the whole region and the international security.
He said the JMP was trying to grab power outside the framework of democracy.
"I am ready to quit, but according to the constitution, which stipulated change through the ballot boxes and free elections," he said.
The JMP agreed to a unity government that included Saleh's ruling General People's Congress on the condition that protests be allowed to continue on the streets, said spokesman Muhammad Qahtan.
Violent anti-government demonstrations have erupted for many weeks across Yemen and the chorus calling for Saleh's ouster has grown louder.
U.S. State Department spokesman Mark Toner said he was aware of press reports around Saleh's acceptance of the GCC proposal and called on all sides to refrain from violence.
"There must be genuine participation by all sides including youth in an open and transparent process that addresses the legitimate concerns of the Yemeni people, including their political and economic aspirations and their calls to quickly bring all perpetrators of violence against protesters to justice," he said.
"A solution to Yemen's problems will not be found through security measures, including the recently adopted emergency laws."
Saleh has been in power since 1978 and served as a staunch U.S. ally in the fight against al Qaeda in the Arabian Peninsula. He has argued he should stay in power because he is best equipped to fight Islamic militancy.
He has also said he accepts opposition demands for constitutional reforms and holding parliamentary elections by the end of the year. He promised not to run for president in the next round of elections.
But earlier this month, Saleh said he would not offer any more concessions to those demanding reforms.
CNN's Elise Labott and journalist Hakim Almasmari contributed to this report.