Washington (CNN) -- President Obama said Wednesday he is "confident" his administration will meet its self-imposed deadline to start a U.S. troop withdrawal from Afghanistan in July 2011.
But there's "going to be some hard fighting" over the next few months, he warned. Taliban and other extremist forces are "tough," he said.
He also stressed that the U.S. campaign in Afghanistan will continue long after the deadline.
"We are not suddenly, as of July 2011, finished with Afghanistan," he said after a meeting with Afghan President Hamid Karzai. "This is a long-term partnership."
Obama said many recent reports of heightened tensions between the U.S. and Afghan governments "were simply overstated."
There will be tensions in "such a complicated and difficult environment," he said in a joint appearance with Karzai at the White House. But "our job is to be a good friend and to be frank with President Karzai."
Karzai's role, in turn, is partly to ensure Afghan sovereignty is respected, he said.
"I am very comfortable with the strong effort that President Karzai has made so far," Obama said. "There are going to be setbacks" and disagreements, but "we share a broad strategy" that can hopefully be set out "in a declaration by the end of this year."
Karzai said that the U.S.-Afghanistan relationship is "strong and well-rooted" and has endured. "There are moments ... we speak frankly to each other," he conceded. But those exchanges only add to the relationship, he said.
Karzai defended his recent meeting with Iranian President Mahmoud Ahmadinejad, telling reporters that while Afghanistan is "a partner and friend" of the United States, it also wants to "remain friendly" with its neighbors.
Alluding to tensions between the United States and Iran, Karzai said he wishes "both countries the best."
Obama said the United States is committed to a "stable, strong, and prosperous" Afghanistan.
He said there is "no denying the progress that the Afghan people have made in recent years," but also said the country still faces major challenges, including "a brutal insurgency."
The U.S. and Afghan governments have reaffirmed their intention to "disrupt, dismantle, and defeat" al Qaeda and its allies, the president said, and noted that U.S. military forces have regained the momentum in Afghanistan.
Karzai thanked Obama for adding "considerable resources" to the U.S. presence in Afghanistan.
Karzai said the two leaders had "a very frank and productive" discussion about, among other things, the protection of Afghan civilians in light of the stronger U.S. military campaign.
He also said the transfer of local detention centers to the Afghan government was a "major point of progress" in the discussions.
Karzai also will meet with Speaker of the House Nancy Pelosi and other House leaders later in the day. He huddled on Tuesday with Secretary of State Hillary Clinton.
Karzai's first visit to Washington after his re-election follows prickly talk centering on the Afghan president's ability to rein in corruption and run an effective government.
He was handed a victory in last August's national vote, marred by irregularities that forced a runoff. Since then, the Obama administration has publicly pressured Karzai to rid his government of graft and improve delivery of services to the Afghan people.
Karzai irritated U.S. officials when he blamed election fraud on foreigners who want a "puppet government" in Afghanistan. He further aggravated his most powerful ally when he told tribal leaders that the U.S.-led military alliance would not move against Taliban fighters in Kandahar "until you say we can."
Media reports have also included harsh criticism of Karzai by a former United Nations diplomat as well as claims that Karzai said he would consider joining the Taliban insurgency.
At one point, the White House indicated it would call off this week's visit.
But in recent weeks, the United States and Afghanistan have sought to play down their differences, rejecting the idea of any dispute between their leaders.
Karzai's visit also comes as questions arise about the timing of a planned U.S.-led military offensive in the Kandahar area that is the spiritual center of the Taliban.
U.S. military leaders acknowledged challenges to the eventual goal of turning over security to the Afghans.
"We will encounter increased violence as our combined security forces expand into Taliban-controlled areas," said Gen. Stanley McChrystal, the allied military leader.
McChrystal offered no specifics on when the offensive might start, but said securing control of the region is a goal of the U.S. mission in Afghanistan.