Kabul — Secretary of State Rex Tillerson made back-to-back, unannounced visits to Afghanistan and Iraq on Monday, flying into both countries under great secrecy out of concern that he might be a target for militants.

As his day looked likely to stretch from before dawn to past midnight, covering almost 4,000 miles, Tillerson and his aides donned flak vests and helmets in Baghdad before boarding helicopters that took them to the U.S. Embassy and elsewhere in the Green Zone to meet with Iraqi Prime Minister Haider al-Abadi and President Fouad Massoum.

Tillerson’s visit to Afghanistan was conducted in even greater secrecy and was announced only after he had left the country. Though he never left Bagram air base, north of Kabul, his short visit showcased U.S. support for the Afghan government after a week of Taliban attacks that killed more than 200 people.

After arriving from Doha, Qatar, Tillerson met with President Ashraf Ghani to reaffirm the U.S. commitment to helping Afghanistan win its war with the Taliban and achieve peace, according to U.S. and Afghan officials.

“I thought it was very important to stop here in Afghanistan coming to the South Asia region as part of the recently announced policy and strategy that President Trump put forth,” Tillerson said after meeting with Ghani for about an hour. He was referring to a U.S. buildup in Afghanistan that will add about 4,000 troops, for a total of 13,500 in the country.

The visit underscores the strong tone that Tillerson is expected to adopt with Pakistan during his visit with interim Prime Minister Shahid Khaqan Abbasi and other officials today.

Earlier this year, Trump threatened Pakistan with sanctions for offering “safe havens” to terrorists near the border with Afghanistan — an allegation that Pakistan officials deny. Senior officials in Islamabad were quoted by Pakistani media on Monday vowing to “work as closely as possible” to defeat terrorist groups on the border but insisting that the U.S. military “stay away from Pakistan.”

At Bagram air base, Tillerson reiterated the importance of Pakistan’s role in reaching peace with the Taliban.

“It is imperative in the end that we are denying safe haven to any terrorist organizations or any extremists to any part of this world,” he said. “This is very much a regional effort … It was rolled out in the strategy itself, demanding that others deny safe haven to terrorists anywhere in the region. We are working closely with Pakistan, as well.”

Tillerson said he will discuss with Pakistani leaders “specific requests” by the Trump administration for actions that cripple the support networks of the Taliban and other extremist groups.

Tillerson also said future U.S. aid to Pakistan will be “conditions based.”

“It will be based upon whether they take action that we feel is necessary to move the process forward for both creating opportunity for reconciliation and peace in Afghanistan but also ensuring a stable future Pakistan,” he said.

Pakistani officials, who last week won some U.S. favor by rescuing an American woman and her family held hostage by a Taliban affiliate for five years, did not respond to messages seeking comment on Monday.

Tillerson’s trip to Afghanistan was cloaked in extraordinary secrecy, even by the standards of previous visits by U.S. secretaries of state.

His public schedule listed a morning meeting at the U.S. Embassy in Qatar that was later “canceled.”

He flew to Bagram from Doha accompanied by a small contingent of pool reporters who are traveling with him on his swing through the Middle East and South Asia. A total news blackout was imposed until after they left the country and returned to Qatar.

After the meeting, Tillerson called on moderate members of the Taliban to join the effort for peace, saying they could be part of the government if they renounce terrorism.

Taliban fighters sought to show strength last week in the face of the mounting U.S. buildup, carrying out suicide attacks that killed dozens of Afghan police officers and troops, along with dozens of civilians.