Castro was born out of wedlock at his father's farm on August 13, 1926.
 His father,
Ángel Castro y Argiz, was a migrant to Cuba from
 He had become financially successful by growing sugar cane at Las Manacas farm in
 and after the collapse of his first marriage, he took his household servant, Lina Ruz González - also of Spanish origin - as his mistress and later second wife; together they had seven children, among them Fidel.
 Aged six, Castro was sent to live with his teacher in
Santiago de Cuba,
 before being
baptized into the Roman Catholic Church at the age of eight.
 Being baptized enabled Castro to attend the La Salle boarding school in Santiago, where he regularly misbehaved, so he was sent to the privately funded,
Jesuit-run Dolores School in Santiago.
 In 1945 he transferred to the more prestigious Jesuit-run
El Colegio de Belén in
 Although Castro took an interest in history, geography and debating at Belén, he did not excel academically, instead devoting much of his time to playing sports.
In 1945, Castro began studying law at the
University of Havana.
 Admitting he was "politically illiterate", he became embroiled in student activism,
 and the
violent gangsterismo culture within the university.
 Passionate about
anti-imperialism and opposing
U.S. intervention in the Caribbean,
 he unsuccessfully campaigned for the presidency of the Federation of University Students on a platform of "honesty, decency and justice".
 Castro became critical of the corruption and violence of President
Ramón Grau's government, delivering a public speech on the subject in November 1946 that received coverage on the front page of several newspapers.
In 1947, Castro joined the Party of the Cuban People (
Partido Ortodoxo), founded by veteran politician
Eduardo Chibás. A charismatic figure, Chibás advocated social justice, honest government, and political freedom, while his party exposed corruption and demanded reform. Though Chibás came third in the
1948 general election, Castro remained committed to working on his behalf.
 Student violence escalated after Grau employed gang leaders as police officers, and Castro soon received a death threat urging him to leave the university; refusing, he began carrying a gun and surrounding himself with armed friends.
 In later years anti-Castro dissidents accused him of committing gang-related assassinations at the time, but these remain unproven.
Rebellion and Marxism: 1947–1950
— Fidel Castro on the Bogotazo, 2009
I joined the people; I grabbed a rifle in a police station that collapsed when it was rushed by a crowd. I witnessed the spectacle of a totally spontaneous revolution... [T]hat experience led me to identify myself even more with the cause of the people. My still incipient Marxist ideas had nothing to do with our conduct – it was a spontaneous reaction on our part, as young people with
Martí-an, anti-imperialist, anti-colonialist and pro-democratic ideas.
In June 1947, Castro learned of
a planned expedition to overthrow the right-wing government of
Rafael Trujillo, a U.S. ally, in the
 Being President of the University Committee for Democracy in the Dominican Republic, Castro joined the expedition.
 The military force consisted of around 1,200 troops, mostly Cubans and exiled Dominicans, and they intended to sail from Cuba in July 1947. Grau's government stopped the invasion under U.S. pressure, although Castro and many of his comrades evaded arrest. Returning to Havana, Castro took a leading role in student protests against the killing of a high school pupil by government bodyguards. The protests, accompanied by a crackdown on those considered communists, led to violent clashes between activists and police in February 1948, in which Castro was badly beaten. At this point his public speeches took on a distinctly leftist slant by condemning social and economic inequality in Cuba. In contrast, his former public criticisms had centered on condemning corruption and U.S. imperialism.
In April 1948, Castro traveled to
Colombia, with a Cuban student group sponsored by President
Juan Perón's Argentine government. There, the assassination of popular leftist leader
Jorge Eliécer Gaitán Ayala led to widespread rioting and clashes between the governing
Conservatives – backed by the army – and leftist
 Castro joined the Liberal cause by stealing guns from a police station, but subsequent police investigations concluded that he had not been involved in any killings.
 Returning to Cuba, Castro became a prominent figure in protests against government attempts to raise bus fares.
 That year, he married
Mirta Díaz Balart, a student from a wealthy family through whom he was exposed to the lifestyle of the Cuban elite. The relationship was a love match, disapproved of by both families, but Díaz Balart's father gave them tens of thousands of dollars to spend on a three-month New York City honeymoon.
— Fidel Castro on discovering Marxism, 2009
Marxism taught me what society was. I was like a blindfolded man in a forest, who doesn't even know where north or south is. If you don't eventually come to truly understand the history of the
class struggle, or at least have a clear idea that society is divided between the rich and the poor, and that some people subjugate and exploit other people, you're lost in a forest, not knowing anything.
That same year, Grau decided not to stand for re-election, which was instead won by his
Partido Auténtico's new candidate,
Carlos Prío Socarrás.
 Prío faced widespread protests when members of the MSR, now allied to the police force, assassinated Justo Fuentes, a socialist friend of Castro's. In response, Prío agreed to quell the gangs, but found them too powerful to control.
 Castro had moved further to the left, influenced by the
Marxist writings of
Friedrich Engels, and
Vladimir Lenin. He came to interpret Cuba's problems as an integral part of capitalist society, or the "dictatorship of the bourgeoisie", rather than the failings of corrupt politicians, and adopted the Marxist view that meaningful political change could only be brought about by proletariat revolution. Visiting Havana's poorest neighborhoods, he became active in the student
In September 1949, Mirta gave birth to a son, Fidelito, so the couple moved to a larger Havana flat.
 Castro continued to put himself at risk, staying active in the city’s politics and joining the September 30 Movement, which contained within it both communists and members of the Partido Ortodoxo. The group’s purpose was to oppose the influence of the violent gangs within the university; despite his promises, Prío had failed to control the situation, instead offering many of their senior members jobs in government ministries.
 Castro volunteered to deliver a speech for the Movement on November 13, exposing the government’s secret deals with the gangs and identifying key members. Attracting the attention of the national press, the speech angered the gangs, and Castro fled into hiding, first in the countryside and then in the U.S.
 Returning to Havana several weeks later, Castro lay low and focused on his university studies, graduating as a Doctor of Law in September 1950.
Career in law and politics: 1950–1952
Castro co-founded a legal partnership that primarily catered for poor Cubans, although it proved a financial failure.
 Caring little for money or material goods, Castro failed to pay his bills; his furniture was repossessed and electricity cut off, distressing his wife.
 He took part in a high-school protest in
Cienfuegos in November 1950, fighting with police in protest at the Education Ministry's ban on student associations; arrested and charged for violent conduct, the magistrate dismissed the charges.
 His hopes for Cuba still centered on Chibás and the Partido Ortodoxo, and he was present at Chibás' politically motivated suicide in 1951.
 Seeing himself as Chibás' heir, Castro wanted to run for Congress in the June 1952 elections, though senior Ortodoxo members feared his radical reputation and refused to nominate him. Instead he was nominated as a candidate for the House of Representatives by party members in Havana's poorest districts, and began campaigning. The Ortodoxo had considerable support and was predicted to do well in the election.
During his campaign, Castro met with General
Fulgencio Batista, the former president who had returned to politics with the Unitary Action Party; although both opposing Prío's administration, their meeting never got beyond polite generalities.
 On March 10, 1952, Batista seized power in a military coup, with Prío fleeing to Mexico. Declaring himself president, Batista cancelled the planned presidential elections, describing his new system as "disciplined democracy": Castro, like many others, considered it a one-man dictatorship.
 Batista moved to the right, solidifying ties with both the wealthy elite and the United States, severing diplomatic relations with the Soviet Union, suppressing trade unions and persecuting Cuban socialist groups.
 Intent on opposing Batista, Castro brought several legal cases against the government, but these came to nothing, and Castro began thinking of alternate ways to oust the regime.