KABUL (Reuters) - A few months ago, the relationship between the new US Administration and the veteran Afghan President looked like a bad marriage, with both sides using every opportunity to complain about each other in public. But when Barack Obama and Hamid Karzai meet this week in Washington for the first time since Obamas election last year, expect the two presidents to get along fine. After months of berating Karzais government as ineffectual and tolerant of corruption, US officials have stopped chiding the man Washington helped install in power in 2001. Karzai, for his part, has toned down what had been increasingly angry complaints about US troops killing Afghan civilians. Officials in both countries say the thaw represents a more realistic assessment in Washington of the challenges Karzai faces and a recognition that berating each other was doing neither side any good as they face a worsening Taliban insurgency together. (Its) an acknowledgment that you cant kick this guy too much because then you weaken him to the point where he is not going to have any legitimacy at all, said a senior US official in Washington on condition he not be identified. Beating him up every day isnt going to achieve anything other than the diminution of the ... whole idea of the Afghan government and the office of the presidency. Siyamak Herawi, a spokesman for Karzai in Kabul, acknowledged there had been some minor tensions in the past. It is natural that misunderstandings occur when there is joint work and joint cooperation. But that is over and we are working in an understanding atmosphere. On the campaign trail, Obama regularly attacked the outgoing Republican administration for failing to put enough emphasis on improving how Afghanistan was governed, a line of reasoning that contained an implicit criticism of the job Karzai was doing. The criticism continued after the inauguration. At her Senate confirmation hearings, new Secretary of State Hillary Clinton said Afghanistan under Karzai had become a narco state. Just two weeks after Obama took office, the New York Times ran a front-page story relating how Vice-President Joe Biden, at a formal dinner in Kabul when still a Senator, was so offended by Karzais refusal to take responsibility for corruption that Biden threw down his napkin and stormed out. Karzai, for his part, was speaking with increasing anger in public about US troops killing civilians, an issue that boiled over into street demonstrations after US forces killed dozens of civilians near the Western city of Herat last August. Washington initially denied it had killed a large number of civilians, but acknowledged three months later it had killed 33. Since then, US officials say they have taken steps to reduce attacks in civilian areas and cooperate better with Afghan authorities to quickly investigate such incidents when they occur. Washingtons criticism eased after veteran diplomat Richard Holbrook took over as Obamas envoy for Afghanistan and Pakistan. According to Waheed Mozhdah, a political analyst who served as an official under Karzai, the Afghan leader warned Holbrook in person that he would resign if Washington did not tone down its criticism. Mozhdah said he learned of the exchange from a government official. The worsening situation across the border in Pakistan, where Taliban have been making advances, may also have helped persuade Washington to ease off on Karzai. While toning down criticism of Karzai, Washington has been increasingly vocal in pressing Pakistan to crack down on militants on its side of the border, and has stepped up attacks by US drone aircraft in Pakistan, measures long urged by Kabul. Obama is concerned about the situation of Afghanistan and particularly of Pakistan, and fears that the situation may get out of control, Mozhdah said. Washington may simply have realised that it is unlikely to find anybody better than Karzai for the job, he added. There are many things he (Karzai) will need to do differently. But it is most likely that he is going to be the one around to do (them), said the US official in Washington.