Trump, who has frequently engaged in inflammatory anti-Muslim rhetoric, defied recent custom by not holding a similar event during his first year in office.
Hundreds of millions of devout Muslims observe the holy fasting month of Ramadan, which is slated to end on June 14 this year.
From sunrise onwards, they abstain from food and drink, breaking their fast at sunset.
There were more than 50 guests. At the head table, Trump sat with Saudi Ambassador Prince Khalid Ben Salman, and Jordanian Ambassador Dina Kawar.
Ambassadors were invited from the United Arab Emirates, Egypt, Tunisia, Iraq, Qatar, Bahrain, Morocco, Algeria and Libya.
"To each of you and to the Muslims around the world: Ramadan Mubarak," Trump said.
"Tonight, we give thanks for the renewed bonds of friendship and cooperation we have forged with our valued partners from all across the Middle East," he said.
Outside the White House, a group of demonstrators displayed slogans and chanted in protest against Trump's efforts to ban immigrants from several Muslim-majority countries.
"We think it's the height of hypocrisy for Donald Trump to ban Muslims with one hand and then invite lead diplomats into the White House and break fast with them," said Bilal Askaryar.
"It's hypocritical and his actions with the Muslim ban and spreading hate speech about Muslims is un-American and un-presidential."
Iftar dinners have been a regular feature on the White House calendar, along with prayer breakfasts, Passover Seders and similar events.
Several American Muslim groups said they would not participate in Wednesday's iftar.