Mr Diaz-Canel, 57, a former provincial communist party chief, has been groomed for the job for several years, serving since 2013 as the country's senior vice-president. The outgoing leader raised his fist in approval.
With Castro watching from the audience, Diaz-Canel made clear that he would defer to the man who, along with his brother Fidel, founded and ruled for six decades what has become of one of the world's last communist governments.
Castro praised Diaz-Canel's leadership as a Communist Party official dating back to the "special period" of the 1990s when Cuba faced a deep economic crisis following the loss of subsidies because of the collapse of the Soviet Union.
Castro's 12 years as president ended shortly after 9 a.m. when the head of the country's electoral commission announced that all but one of the 604 members of the National Assembly had approved Diaz-Canel as sole candidate.
Thursday's session was held on the 57th anniversary of Cuba's 1961 defeat of a CIA-backed Cuban exile invasion at the Bay of Pigs, a victory that Havana celebrates as a symbol of its resistance to "imperialist" pressure for change from Washington.
Diaz-Canel's speech set a course for his first term, in which he will have to strike a balance between defending Cuba's socialist system and reforming it enough to satisfy a young generation hungry for better economic conditions.
In his inaugural speech, Diaz-Canel said that his mandate was "to ensure the continuity of the Cuban revolution at a key historic moment".
Although he has advocated fewer restrictions on the press and a greater openness to the internet, he also has a ruthless streak, with harsh words for Cuba's dissidents and the United States. "Cuba needs him, providing ideas and proposals for the revolutionary cause, orienting and alerting us about any error or deficiency, teaching us, and always ready to confront imperialism".
But, steps towards a normalization of ties have been severely curtailed since Donald Trump arrived in the White House previous year.
One of the fiercest congressional critics of Cuba's government says the island's new president is a "thug" who is just the "same as the old boss".
Florida Republican Rep. Ileana Ros-Lehtinen says Congress sees Thursday's transition as "business as usual" and doesn't expect diplomatic relations to improve under Diaz-Canel.
Even though Díaz-Canel was born after the revolution, he is a staunch ally of Raúl Castro and is not expected to make any radical changes. It's the communist, authoritarian, totalitarian regime.