Former Secretary of Defense James Mattis criticized President Obama’s orders to withdraw forces in Afghanistan without consideration for what was happening on the ground.

Mattis, in an interview with NPR, said he had been given “two contradictory objectives” in 2011 when he was leading Central Command and overseeing the wars in Afghanistan and Iraq.

"The forces under my command at CENTCOM were to degrade the Taliban while building up the Afghan army. They were also to withdraw on a strict timetable, independent of circumstances on the ground. We could do one or the other, but not both,” he said.

"What you have got to do is figure out what it is you intend to do at the outset [of a war] and then hold firm to that and don't half-step it," Mattis said. "I think that we have had serious policy challenges in figuring out exactly what it is we intend to do and then holding firm to that vision."

In recent months, the U.S. has been in negotiations with the Taliban about withdrawing American troops. About 14,000 troops remain in Afghanistan.

Mattis, 68, also took another swipe at President Trump’s embrace of isolationism that has been a focal point of his presidency.

Mattis, who did not mention Trump by name, stressed that such isolation could threaten America’s global standing.

"Throughout history, we see nations with allies thrive, and nations without allies wither," he said.

Trump has often criticized American allies, particularly NATO members, arguing that they are taking advantage of the U.S. for their security. But Mattis said U.S. allies are needed, especially in combating terrorism.

"They were alongside us because they shared the values, the sense that terrorism was a threat to everyone," Mattis said of eight allied nations fighting alongside the U.S. in Afghanistan. "So when you go into these kind of situations, you need every ally you can get your hands on. You need all of them. You need their votes in the United Nations. You need their troops on the ground."

Mattis’ comments come ahead of the release of his book, Call Sign Chaos: Learning to Lead, which goes on sale Tuesday.

He shared similar sentiments last week in an essay published in the Wall Street Journal.

“Alone, America cannot protect our people and our economy. At this time, we can see storm clouds gathering. A polemicist’s role is not sufficient for a leader. A leader must display strategic acumen that incorporates respect for those nations that have stood with us when trouble loomed. Returning to a strategic stance that includes the interests of as many nations as we can make common cause with, we can better deal with this imperfect world we occupy together. Absent this, we will occupy an increasingly lonely position, one that puts us at increasing risk in the world,” Mattis wrote.