(L-R) Democratic presidential hopefuls billionaire-philanthropist Tom Steyer, Massachusetts Senator Elizabeth Warren, Former Vice President Joe Biden, Vermont Senator Bernie Sanders, Mayor of South Bend, Indiana, Pete Buttigieg and Minnesota Senator Amy Klobuchar stand on stage ahead of the seventh Democratic primary debate of the 2020 presidential campaign season co-hosted by CNN and the Des Moines Register at the Drake University campus in Des Moines, Iowa on January 14, 2020.

The 2020 Democratic presidential contenders took the stage together Tuesday for the final time before nominating contests start.

A largely cordial primary race has turned more adversarial in recent days with less than three weeks to go until the Feb. 3 Iowa caucuses, the first time a state will award delegates in 2020.

Tuesday's Democratic debate, hosted by the Des Moines Register and CNN, took place at Drake University in Des Moines, Iowa.

As debate qualifying standards get tougher and more candidates drop out of the race, the number of participants has dwindled. Only six Democratic candidates took the stage together Tuesday in a field that has skewed older and whiter as it narrows.

Former Vice President Joe Biden

Former South Bend, Indiana, Mayor Pete Buttigieg

Sen. Amy Klobuchar, D-Minn.

Sen. Bernie Sanders, I-Vt.

Billionaire activist Tom Steyer

Sen. Elizabeth Warren, D-Mass.

The contenders first faced nearly 30 minutes of questions about their credentials to handle the rising specter of war in the Middle East following the U.S. killing of Iran's top general, Qasem Soleimani, earlier this month. Candidates have tried to leverage their foreign policy records to garner support amid the sharpened focus on Iran.

Sanders highlighted his opposition to the 2003 invasion of Iraq and push last year to stop U.S. support for a Saudi-led intervention in Yemen. Biden, meanwhile, said he worked during the Obama administration to end the Iraq War — while admitting it was a "mistake" to authorize the use of military force in the country when he was in the Senate.

Sanders defended his decision as a House member to vote for a military force authorization in Afghanistan, and again attempted to distance his record on Iraq from Biden's.

"I took to the floor, I did everything I could to prevent that war. Joe saw it differently," he said.

Klobuchar, asked whether she would remove forces from the Middle East, said she would "leave some troops there." Warren, meanwhile, contended that "we need to get our combat troops out." Buttigieg, an Afghanistan veteran, criticized the president for sending more troops to the region.

The candidates were asked about whether they would meet with North Korean dictator Kim Jong Un, as President Donald Trump did. In Iowa, a state walloped by the president's trade war with China, the rivals also sparred over their records on trade.

Sanders and Warren debated the United States-Mexico-Canada Agreement, a revised North American trade deal that the U.S. expects to ratify this week. Sanders argued it did not go far enough to address climate change, and said "we can do much better than a Trump-led trade deal."

Warren said farmers in Iowa "are hurting" and highlighted improvements on the North American Free Trade Agreement. Sanders also contrasted his opposition to NAFTA and the Obama-era Trans-Pacific Partnership from Biden's support for both trade pacts, saying the two candidates have a "fundamental disagreement."

Tensions among the top candidates escalated in the days before the debate. Warren said Monday that Sanders told her during a 2018 meeting that a woman could not win the presidential election.

Asked about the remark during the debate, Sanders responded, "I didn't say it."

Warren appeared to acknowledge that her rival did say it, but added that "Bernie is my friend and I am not here to try to fight with Bernie." She then highlighted that she and Klobuchar have won all of their elections — while the men on the stage have lost 10 elections combined.

Recent Iowa polls have found four Democrats have a realistic shot at winning the most delegates in the first-in-the-nation caucuses. Biden has 20.7% of support, about even with Sanders at 20.3%, according to a RealClearPolitics polling average.

Buttigieg and Warren follow at 18.7% and 16%, respectively.

Subscribe to CNBC on YouTube.