Former defense secretary Jim Mattis defended American efforts to rebuild Afghanistan as part of the 18-year-old U.S. war there, saying Friday that “we had to try to do something in nation-building, as much as some people condemn it, and we probably weren’t that good at it.”

Mattis described the progress that has been made in Afghanistan since the U.S. military invaded after the Sept. 11, 2001, terrorist attacks. Speaking to journalists at The Washington Post, he cited an increase in the number of Afghan women who are educated, the development of Afghan diplomats and the inoculation of civilians against disease.

Mattis, who oversaw the war as the four-star head of U.S. Central Command from 2010 to 2013, said violence in Afghanistan is “so heartbreaking that it can blind you to the progress,” and he acknowledged that the United States made a strategic mistake by not paying enough attention to the country as the administration of George W. Bush launched the war in Iraq in 2003.

“That we didn’t do things right, I mean, I’m an example of it,” Mattis said, recalling that as a one-star general, he was pulled out of Afghanistan in the spring of 2002, promoted and told to prepare for war in Iraq.

“I was dumbfounded,” he said. “But we took our eye off of there.”

The comments came in response to questions about investigative reporting by The Post that outlines mistakes made in the war. The series, called “The Afghanistan Papers,” includes previously unpublished interviews and memos in which senior officials privately expressed misgivings about the campaign, even as they publicly touted its progress.

As a general, Mattis was among those who frequently spoke about the progress he saw in Afghanistan.

In 2010, Mattis testified before Congress that the military component of the U.S. strategy in Afghanistan was sound, and that by “steadfastly executing our strategy we will win in Afghanistan.”

In March 2013, he testified that it was “obviously a combination of progress and violence” on the ground but that the Afghan forces were “proving themselves capable.”

“I think we may have to look at how we’re measuring them since they’re measuring themselves against the enemy and they’re proving themselves there,” Mattis said.

By 2015, the United States was dispatching its own Special Operations troops to stave off security disasters in the south and had stopped a planned withdrawal as scores of Afghan soldiers were being killed each month.

Mattis said the reports in The Post have prompted the families of fallen service members and some veterans to contact to him.

“You can imagine what it’s like for the families, and I have heard from them,” he said. “The emails are coming in.”

Mattis said he assured them that U.S. officials, including former secretary of state Hillary Clinton and Ryan Crocker, a former U.S. ambassador to Afghanistan, “were not papering over any of this.”

“That it was hard, harder than hell, and that it was understood by all of us,” he said. “It is hard to explain that you can build on nothing. You had to literally build the ground, and that takes years to kind of build people who can be diplomats in a country that had known nothing.”

“I salute” the investigative reporting, he said, but he said it was “not really news,” because mistakes made in the Afghanistan war have been reported on by journalists for years.

“I don’t know why it’s such a revelation,” he said.

The new reports by The Post draw on interviews with scores of senior U.S. officials. They were carried out by the Office of the Special Inspector General for Afghanistan Reconstruction (SIGAR) and withheld from the public until The Post won a three-year court battle through the Freedom of Information Act.

Government interview records obtained by The Washington Post reveal U.S. officials misled the American public about the Afghanistan war for nearly two decades. (The Washington Post)

Mattis said there are “lots of lessons to be learned, and that’s why those documents were pulled together.” But he espoused misgivings that they were publicized in the media, saying the comments will “be used now as a club.”

“Don’t get me wrong,” Mattis said. “I know why you did it, and I salute why you did it. But one of the unfortunate aspects is it could be a governor on those who want to go forward and collect self-critical information. Because that’s what it was, by an IG.”

At a Washington Post Live event later in the day, Mattis said the difficulties in Afghanistan were well known before the series was published.

“I have walked the ground in Afghanistan with your reporters beside me, who were embedded in the units, who were watching this close-up,” he said. “The reporting, I thought, was pretty accurate. The idea that there was any kind of an effort to hide this perplexes me.”

Read more stories in The Afghanistan Papers series: