Cuba gained formal independence from the U.S. on May 20, 1902, as the Republic of Cuba. Under Cuba's new constitution, the U.S. retained the right to intervene in Cuban affairs and to supervise its finances and foreign relations. Under the Platt Amendment, the U.S. leased the Guantánamo Bay naval base from Cuba.
Following disputed elections in 1906, the first president, Tomás Estrada Palma, faced an armed revolt by independence war veterans who defeated the meager government forces. The U.S. intervened by occupying Cuba and named Charles Edward Magoon as Governor for three years. Cuban historians have attributed Magoon's governorship as having introduced political and social corruption. In 1908, self-government was restored when José Miguel Gómez was elected President, but the U.S. continued intervening in Cuban affairs. In 1912, the Partido Independiente de Color attempted to establish a separate black republic in Oriente Province, but was suppressed by General Monteagudo with considerable bloodshed.
During World War I, Cuba exported considerable quantities of sugar to Britain. Cuba was able to avoid U-boat attacks by the subterfuge of shipping the sugar to Sweden. The Menocal government declared war on Germany very soon after the United States.
A constitutional government was maintained until 1930 when Gerardo Machado y Morales suspended the constitution. During Machado's tenure, a nationalistic economic program was pursued with several major national development projects which included the Carretera Central and El Capitolio. Machado's hold on power was weakened following a decline in demand for exported agricultural produce due to the Great Depression, attacks by independence war veterans, and attacks by covert terrorist organizations, principally the ABC.
During a general strike in which the Communist Party sided with Machado, the senior elements of the Cuban army forced Machado into exile. The Party then installed Carlos Manuel