Democratic presidential candidate Sen. Cory Booker, D-N.J., second from left, hugs Rep. Tim Ryan, D-Ohio, while Sen. Elizabeth Warren, D-Mass., hugs former Housing and Urban Development Secretary Julian Castro at the end of a Democratic primary debate hosted by NBC News at the Adrienne Arsht Center for the Performing Arts in Miami. In between them is New York City Mayor Bill de Blasio. Picture: Wilfredo Lee/AP

Washington - Ten of the more than 20 Democrats running for president faced off in Miami on Wednesday in the first of two debates this week as opposition party candidates jostle for the chance to take on US President Donald Trump in 2020.

American voters got their first look at just under half the crowded Democratic field on a single stage, with the three women and seven men gathered for the televised event.

Of the field of 25, only 20 qualified to take part in the debate.

The group included Senator Elizabeth Warren, whose support according to polls is the highest among the 10. The front-runner among the Democrats, former vice president Joe Biden, and Senator Bernie Sanders, another candidate whose polling number are among the highest, are scheduled to debate Thursday night.

Though the 2020 presidential election is still 16 months away, Democrats are eager to winnow down the field and choose a candidate they believe has the best chance to beat Trump.

Facing each other on the day a haunting photo of an immigrant father and daughter who drowned in the Rio Grande at the US-Mexico border was published, the candidates sparred over immigration policy, but all agreed that separating families at the border, a controversial Trump administration policy affecting migrants who cross into the country with children, was wrong.

The candidates also answered questions on foreign policy, including tensions in the Middle East, health care, labour law and climate change.

Asked to name the greatest geopolitical threat to the US, Washington Governor Jay Inslee received loud cheers when he said, "The biggest threat to the security of the United States is Donald Trump."

Senator Amy Klobuchar took a jab at Trump's belligerent tweets and decision to pull back from launching attacks on Iran in retaliation for the downing of a military drone 10 minutes before the plan was to go into action.

"This president is literally, every single day, 10 minutes away from going to war, one tweet away from going to war," she said. "I don't think we should conduct foreign policy in our bathrobe at 5 in the morning."

But the candidates did not come down hard on Trump, as plenty of time remains to do that in debates scheduled to take place over the next several months. They stuck instead to outlining their own platforms and trying to stand out in the pack.

Warren blasted large corporations that she said don't pay their fair share in taxes and devote themselves strictly to profit.

"What's been missing is courage, courage in Washington to take on the giants," she said.

Three of the candidates - former US Representative Beto O'Rourke and Senators Cory Booker and Julian Castro - slipped into Spanish in making their pitches to voters, while US Representative Tulsi Gabbard, a combat veteran of the Iraq war, played up her military experience.

Currently a major in the US Army National Guard, Gabbard warned against a war with Iran and clashed with US Representative Tim Ryan when he said the US must stay "engaged" in Afghanistan.

"We must have our State Department engaged. We must have our military engaged to the extent they need to be," Ryan said in response to a question about the lengthy war in Afghanistan.

Gabbard told Ryan she found his comment "unacceptable" and said the US must bring its troops home from Afghanistan.

"We are in a place in Afghanistan where we have lost so many lives. We've spent so much money," she said, adding that she'd rather see that money spent on domestic programmes.

Trump, who was en route to the G20 summit in Japan during the debate, expressed his opinion in a single-word tweet: "Boring," he wrote.

Nate Silver, a pollster, also saw little excitement in the debate.

"On a scale of 0 to 10, where 0 is the debate having no impact and 10 is a huge impact, I'd guess this was like a 2 or a 3," he tweeted.