President Obama condemned the deadly terrorist attacks in Brussels, Belgium, Tuesday morning while "pledging to stand in solidarity" with the U.S. ally and do "whatever is necessary" to bring the perpetrators to justice.

"The thoughts and prayers of the American people are with the people of Belgium," he said before delivering an address to the Cuban people in Havana. "We stand in solidarity with them … we will do whatever is necessary to support our ally Belgium to bring to justice whoever is responsible."

The president said the world must "fight the source of terrorism" together, and said the attacks are "yet another reminder that the world must unite" to fight terrorism.

"We must be together, regardless of nationality or race or faith, in fighting against the scourge of terrorism," he said.

The president was reacting to the terrorist attacks the struck the Belgian capital Tuesday morning that killed 34 people and injured 170. Obama went on to deliver his planned address to the Cuban people.

In the afternoon, the first family was planning to watch a baseball game between the Tampa Bay Rays and Cuba's national team before heading to Argentina for two days.

The White House has not said whether the president plans to cut his trip short because of the attacks.

This is the second time over the past five months that Obama has been abroad during a major terrorist attack. He was in Turkey for the G20 summit when the Paris attacks killed 130 people and injured 368 more Nov. 16.

At the time, he faced a barrage of questions from international journalists as he repeatedly stressed confidence in his approach to combating terrorism and handling the civil war in Syria, as well as the rise of the Islamic State there.

"We have the right strategy and we're going to see it through," Obama said at the time. "There will be an intensification of the strategy we have put forward but the strategy we have put forward is the strategy that will ultimately work," though he added it will take time.

Secretary of State John Kerry spoke to Belgian Foreign Minister Didier Reynders to express his condolences for the loss of life in the attacks and to reaffirm that the United States will stand with the people of Belgium as they cope with the aftermath of this violence, according to a State Department read-out of the call.

"Kerry praised the quick work of first responders and offered U.S. support to investigators." the State Department said. "Both ministers agreed that that the perpetrators must be brought to justice and that attacks such as these underscored the need for a continued and concerted push by all nations to counter violent extremism."