A man accused of raping a St Andrews University student kept her phone and got his friend to return it to her the next day, a court has been told.

Dominic Hurst, 24, from Ramsbottom near Bury in Lancaster, said his close friend Stephen Coxen had kept the phone after going home with a woman known as Miss M during freshers week in September 2013.

Miss M accuses Coxen of raping her and is suing him for nearly £100,000 in damages in a rare civil action after he was cleared of rape at a criminal trial in 2015. He denies the charge and is defending the action.

Hurst, then a maths student at St Andrews, told Edinburgh sheriff court that Coxen was visiting that weekend because it was freshers week. After sharing a bottle of vodka at home, Hurst said, the two men went to the town’s Lizard Lounge nightclub but became separated after he had seen Coxen with Miss M.

He told Simon di Rollo QC, Miss M’s advocate, that Coxen returned to his flat at about 3am on Saturday morning, but he could not remember Coxen sharing anything of what he had been doing or with whom.

The next morning both he and Coxen were woken by the mobile phone’s alarm going off because someone was trying to locate it. They went back to sleep, to be woken by its alert some hours later.

Hurst was unclear about whether it was done via Facebook or through text messages, but he arranged to return the phone to its owner, Miss M, later that day. When he did so, Coxen stayed away from the house at the end of the path with another of Hurst’s friends.

Hurst denied that Coxen had told him he had found the phone in the street. He said Coxen had claimed he kept the phone because Miss M’s jeans did not have pockets; the court heard earlier this week that Miss M had carried her purse and phone in a bag.

Hurst told the court he could not recall why he agreed to return the phone and not Coxen. He said he believed he did so “because it is the right thing to do” but later said “I presumed it would be awkward” for Coxen to hand it back because he presumed his friend and Miss M had had intercourse.

He later found out that Coxen had been ejected from the Lizard Lounge after an altercation with another customer. Di Rollo asked Hurst whether he was the subject of a court order “as a result of various things which have happened to [Miss M] at various times”. Hurst confirmed that he was subject to a court order and that he did not believe Coxen would rape someone.

Questioned by Coxen’s counsel, Stephen O’Rourke QC, Hurst confirmed that in February and March 2014 he had told police investigating Miss M’s rape allegations that he recalled seeing Coxen and Miss M “kissing and being affectionate” in the nightclub.

Questioned on that account by O’Rourke and Di Rollo, Hurst said he could no longer remember that happening. Under cross-examination from Di Rollo, Hurst confirmed that in Coxen’s trial in late 2015 he had again said he could not remember seeing the pair kissing.

A second witness, a friend of Miss M’s at St Andrews, whom lawyers asked not to be named, gave evidence by video link from the US. She told the court Miss M had been a “bubbly, energised person” before the alleged incident but then became much more closed off.

The next day Miss M “was in tears, red-faced, not really able to speak full sentences to me,” the witness said. “I knew that something was wrong. I knew she had gone home with someone and that it was upsetting to her, but she didn’t share too much with me because she was upset.

“Later on, not that day but in the weeks after, slowly she started to talk to us about what had kind of happened. I understood it was a sexual encounter that wasn’t a positive experience.”