WASHINGTON — As the United States military steadily reduces its presence in Haiti, President Obama pledged on Wednesday to remain committed to providing financial assistance and humanitarian relief to help Haitians rebuild and recover from their devastating earthquake two months ago.

“The situation on the ground remains dire and people should be under no illusions that the crisis is over,” Mr. Obama said after meeting with President René Préval of Haiti. With spring rains ahead, he added, “the challenge is now to prevent a second disaster.”

The two leaders stood side by side in a ceremony in the Rose Garden, after a private meeting in the Oval Office, where Mr. Obama received an update on conditions in Haiti. The Navy said the hospital ship Comfort left Haiti on Wednesday for its home port, Baltimore.

Mr. Préval offered his gratitude to the United States for its “massive, spontaneous, generous help” after the earthquake on Jan. 12 that killed more than 230,000 people and left more than one million homeless. He said the tragedy should serve as a warning for the world that the effectiveness of relief efforts “must be improved.”