Hun Sen broke with Pol Pot in 1977 and allied himself with Vietnamese forces. His political fortunes were greatly enhanced by the Vietnamese invasion of Cambodia. When Vietnamese armies captured Phnom Penh in 1979, Hun Sen became part of a new government supported by Vietnam. Having developed cordial relations with the Vietnamese, he became one of the preferred choices for political leadership. In the new government established by the People's Revolutionary Council, he became minister of foreign affairs and vice premier in 1979. Hun Sen moved rapidly to the center of power in the following years by becoming a member of the Politburo of the People's Revolutionary Party (PRP) in 1981 and then chairman of the Council of Ministers of the PRP and premier in 1985.
In 1989, Vietnamese troops withdrew from Cambodia, setting the stage for national reconciliation. A peace agreement, drafted by five permanent members of the United Nations (UN) Security Council, was signed in October 1991, opening the way toward a comprehensive settlement involving the largest peacekeeping mission in UN history. The UN Transitional Authority in Cambodia (UNTAC) had a budget of US $2.8 billion and a staff of 22,000 soldiers and civilians from more than 50 countries. UNTAC was responsible for preparing the country for democratic elections by supervising the government's departments of foreign affairs, information, finance, defense and public security, and for laying the legal and administrative framework for a democratic society.
Despite widespread violence orchestrated by the Khmer Rouge and Hun Sen's forces in the 1993 national elections, 90% of the Cambodian electorate voted. However, Pol Pot's Khmer Rouge boycotted the elections and maintained its guerrilla campaign. The royalist National United Front for an Independent Neutral, Peaceful and Cooperative Cambodia (FUNCINPEC) Party, led by Sihanouk's eldest son, Ranariddh, received 45% of the vote and 58 of 120 National Assembly seats. The incumbent Cambodian People's Party (CPP), led by Hun Sen, received 38% and 51 seats. Questions about electoral irregularities threatened the peace agreement until Sihanouk persuaded both Ranariddh and Hun Sen to become co-prime ministers. On 21 September 1993, the National Assembly ratified a new constitution that resurrected the monarchy under King Norodom Sihanouk. With his new powers, Sihanouk appointed Prince Ranariddh as first co-prime minister and Hun Sen as second co-prime minister. An uneasy relationship between Hun Sen and Ranariddh followed.