Castro chose law as his field and entered the University of Havana for his degree in law. It was in this university that he became involved in politics. In 1947 he entered the group of Eduardo Chibas known as Partido Ortodoxo which was involved in the process of explaining the corruption that was prevalent in Cuba and it stress upon developing independence in Cuba from foreign intervention in the issues of the country particularly the involvement of the United States. Though Chibas was not successful in his mission and he shot himself because of his failure to win elections, Castro was inspired by him and worked on his principles.
Castro got married in 1948 to Mirta Diaz Balart who belonged to a very rich family. Though, he received an exposure to the elite and political figures through this marriage but it did not prove to be a successful marriage and he separated from his wife in 1955. Castro completed his education in 1950 and started practicing law and at the same time became politically active. He had very high hopes of achievement in the upcoming elections and expected himself to be elected in the parliament in 1952. But events took a different turn when General Fulgencio Batista formed a coup against Carlos Prío Socarrás who was the then ruling president and took over and suspended the upcoming elections.
Batista was very influential. He legalized his actions with the United States with the help of his sources and started dictating the land of Cuba. Castro stopped his law practice and directed himself entirely towards politics. Fidel Castro and other members of the Partido Ortodoxo party who were looking forward to elections were disappointed with this action. This group revolted against the government by attacking Moncada Barracks on July 26 1953 but they were unsuccessful. Most of them were killed and Fidel Castro and his brother Raul Castro were given sentences of 15 years of imprisonment. Castro was released two years later only.