MI6 spy Gareth Williams tied himself to his bed "to see if he could get free" years before his body was found in a padlocked bag, his inquest has heard.

Mr Williams was working for GCHQ in Cheltenham when his landlord and landlady in the town discovered him with his wrists attached to the head board. They concluded the act was "more likely to be sexual than escapology," the hearing was told.

In a written statement read to Westminster Coroner's Court, his landlady Jennifer Elliot described the startling scene that confronted her and her husband in the middle of the night three years before their tenant's death.

Ms Elliot, who rented out an annex to her home to Mr Williams, said: "We were in bed and we heard Gareth shouting for help. It was about 1.30am and during winter. We both got up, got the spare key and opened the door to the annex.

"I called 'are you OK?' Gareth replied 'can you help me?' We went upstairs and found him lying in his bed with both hands tied with material attached at the headboard."

The spy was dressed in boxer shorts, with the bedclothes pulled over his legs, and was not aroused but was "very embarrassed", she said.

When police entered Mr Williams's flat they found some £20,000-worth of high-end women's clothing and shoes among his possessions, the inquest has heard. Elizabeth Guthrie, a friend of Mr Williams, was asked in court whether the spy had ever expressed an interest in cross-dressing. "Nothing of a sexual bent but we were going to a fancy dress ball together," she said. "He was going as a ninja, not as a queen."

She also suggested that his collection of female clothing might have been "Gareth's attempt at a support strategy for someone. They certainly would not have been for him". Asked about his sexuality, she said: "I have a personal view that he was straight."

Detective Chief Inspector Jackie Sebire, the leading officer in the case, told the court she always assumed "a third party had been involved in the death or by putting the body in the bag".

Mr Williams's body was found locked in a hold-all in his flat in Pimlico, London, in August 2010 but 20 months on his death still remains a mystery.