Secretary of State Rex Tillerson made back-to-back, unannounced visits to Afghanistan and Iraq.

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, on his swing through the Middle East and South Asia, 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 on Tuesday.

Earlier this year, Trump threatened Pakistan with sanctions for offering “safe havens” to terrorists near the border with Afghanistan — an allegation that Pakistani officials deny. On Monday, Pakistani media quoted senior officials in Islamabad as pledging 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, her Canadian husband and their children held hostage by a Taliban affiliate for five years, did not respond to messages seeking comment 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 from Doha to Bagram accompanied by a small contingent of pool reporters who are traveling with him. A total news blackout was imposed until after they left the country and returned to Qatar. He arrived about 11:30 a.m. at Bagram air base, where he was met by Gen. John Nicholson, commander of the U.S.-led NATO effort in Afghanistan, and U.S. Ambassador Hugo Llorens.

Tillerson then met with Ghani, Abdullah Abdullah, the nation’s chief executive, and other top Afghan officials at the airfield, where they discussed the importance of weeding out corruption and ensuring that the 2018 parliamentary elections go forward as scheduled to strengthen the country’s stability.

In a statement, Ghani vowed to follow through. “The Afghan people are supportive of the strategy and hope that it will ensure peace and security,” he said.