Secretary of State John F. Kerry arrives at Kabul International Airport on April 9 for a day of meetings with Afghan leaders. (Jonathan Ernst/Reuters)

Secretary of State John F. Kerry on Saturday urged Afghan’s disputatious leaders to cooperate and demonstrate to donor nations that they are capable of managing military and financial aid.

Kerry came to Afghanistan to tell the two political rivals — who share power in an uneasy arrangement that Kerry brokered 18 months ago — that they must get their act together before donor conferences later this year.

“Democracy requires credible institutions,” Kerry said, standing behind President Ashraf Ghani after separate meetings with him and later with Ghani and Chief Executive Abdullah Abdullah. “More than that, it requires people from different political, ethnic and geographic factions to be able to come together and work for the common good.”

Ghani and Abdullah both claim to have won the 2014 presidential election. By many accounts, they have difficulty communicating with each other, and the government is stalemated on several basic issues.

Meanwhile, the supposed unity government they head has grown increasingly unpopular and unworkable as a stumbling economy and a resilient Taliban fuel a brain drain of Afghan migrants to Europe.

The visit to Kabul was Kerry’s second unannounced stop in two days, following a day in Baghdad. The advance secrecy surrounding these visits underscores the precarious security and political instability in the two countries that a U.S.-led coalition invaded after the Sept. 11, 2001, terrorist attacks.

[Kerry arrives in Baghdad in show of support for government]

In both countries, the secretary confronted a bleak political landscape beset by strikingly similar economic and security crises.

In Baghdad, the government is preparing an offensive to retake Mosul from the Islamic State and is under pressure to root out corruption and find the money to fund basic services.

In Kabul, the challenges are even greater. The country’s poverty rate has risen to 49 percent as foreign troops have withdrawn, leaving thousands of Afghans unemployed.

The Taliban and branches of Islamic militant groups such as the Islamic State, said to be mostly made up of disaffected Taliban fighters, still control parts of the countryside. Prospective peace talks have stalled, and the Taliban has shown no sign it will come to the negotiating table.

The fighting between government troops and insurgents has led to the closure of hundreds of schools and propelled an exodus of Afghans seeking a better life elsewhere. Afghans represent one in five migrants arriving in Europe, second only to Syrians in number.

In his opening remarks at a meeting with Foreign Minister Salahuddin Rabbani, Kerry adopted the tone of a coach gently chiding a team with a string of losses at season’s end.

He said there was no time to spare, citing two critical meetings later this year. NATO nations meet in Warsaw in July to discuss security assistance to Afghanistan, and a Brussels conference on development aid for the country is scheduled for October.

“To make them a success, we need to maximize each and every day between now and those meetings,” Kerry said as he sat beside Rabbani in a large, ornately decorated room at the presidential palace, lined with oil portraits of Afghan leaders through the ages.

“We need to make certain that the government of national unity is doing everything possible to be unified and deliver to the people of Afghanistan,” Kerry continued. “We each have a huge stake in continuing your country’s forward momentum.”

Ghani appeared to agree, telling reporters he hoped to come to Warsaw and Brussels with a comprehensive reform program that will target corruption.

Adding to the sense of urgency is the prospect of a dwindling U.S. military presence.

Currently, 9,800 U.S. troops serve in Afghanistan, a level President Obama wants to maintain through the fighting season. But he has set a goal of 5,500 by the end of his term.

Despite the concerns voiced by Kerry, U.S. officials maintain that Afghanistan has made strides since the U.S. invasion in 2001. Kerry mentioned that when he came to Afghanistan as a senator 14 years ago, almost all the children in school were boys. Now one-third are girls.

Read more:

U.S. troops are back in restive Afghan province, a year after withdrawal

Kerry tells Iran to join efforts for peace in Yemen and Syria

Kerry arrives in Jordan to discuss Syrian civil war, battle with ISIS