A homeless 16-year-old resorted to living in a tent for nine months and selling his belongings to survive after two councils failed to assess his needs or provide him with accommodation, an investigation has found.

The local government ombudsman has condemned the "inexcusable" handling of the case by Kent county council and Dover district council, praising the unnamed boy's resilience in the face of "crushingly difficult circumstances".

The housing charity Shelter, which took up the case, said that many councils were failing to meet the needs of homeless 16- and 17-year-olds despite court rulings and government guidance that have confirmed their responsibilities.

The teenager, whose identity is not being disclosed, had been taken into care by Kent and fostered from the age of 12 to 14. He returned to live with his mother, who had mental health problems, but she told him to leave after an argument when he was 16.

By that time he had been involved in drugs and crime and had fathered a baby.

The ombudsman, which investigates complaints against local authorities, said the boy had shown willingness to improve his life.

Dover council had offered him bed-and-breakfast accommodation, but he had declined it because he was worried it was in an area where he might be tempted back to offending and drug use.

So he spent most of the next nine months, including during a spell of heavy snow, in a tent, pitched at various locations in rural Kent. On some nights he slept on friends' sofas.

His physical and mental health suffered, the report said, and he sold most of his possessions to get by.

The report describes how he suffered back pain, lost a lot of weight, and at one point developed a chest infection while living in the tent.

A voluntary sector youth centre manager, who supported the boy and gave him meals, said he contacted the children's services of Kent council about him on three occasions but no action was taken.

After other agencies, including the police, the Youth Offending Service, the YMCA and a local drug and alcohol service, expressed concern, Dover district council agreed to offer the boy a one-bed flat. But the council then demanded an adult signed up as guarantor to the tenancy, and rejected an offer of £1,000 from Kent and £500 from the youth centre manager. Ultimately, it backed down on those requirements in the face of threats of legal action by Shelter.

Anne Seex, one of the local government ombudsmen, said Kent had failed to support the boy as a "child in need" as defined by the Children Act, while Dover had failed to fulfil its duty to him as a homeless person.

Both councils flouted a joint policy they had agreed upon for homeless young people.

Recommending each council pay the boy more than £5,050 in compensation, Seex said the teenager was: "Remarkably determined and resilient in the face of crushingly difficult circumstances and was well supported by the youth centre. The failures of the two councils could have easily tipped him into a spiral of drug use and crime."

Dover council apologised, agreed to pay the compensation, and has improved its procedures.

Campbell Robb, Shelter's chief executive, said the case showed it was vital for councils to comply with their legal duty to help homeless 16- and 17-year-olds. "Without this, vulnerable young people can end up falling through the cracks between children's services and housing departments, leaving them out on the streets."