The daughter of Hunter Biden has told jurors that her father seemed “great” and “hopeful” around the time he purchased a gun in October 2018.

Naomi Biden, 30, gave surprise testimony in court in her father’s gun trial after she was called to the witness stand by his defence team.

She said she did not see her father use drugs at any point in 2018, and that he was living with a sober coach late that year.

The US president’s son is accused of lying about his drug use on a form when purchasing the firearm and ammunition from a Wilmington, Delaware, gun shop on 12 October 2018.

Mr Biden, 54, has pleaded not guilty to the charges, with his defence team saying he was in recovery at the time and therefore did not lie on the paperwork.

It is the first trial for the son of a sitting US president. Mr Biden could face up to 25 years in prison if convicted.

Prosecutors wrapped up their case early on Friday after calling their remaining two witnesses.

One of them, FBI forensic chemist Jason Brewer, testified that a “minimal” amount of cocaine was found in a leather pouch that contained Mr Biden’s firearm.

But he said he could not say for sure how the cocaine got there, or who it belonged to.

Mr Biden’s defence team then began calling their own witnesses, starting with Jason Turner, who worked at the gun shop where Mr Biden purchased the firearm, and Ron Palmieri, the owner of the shop.

Their testimony featured a combative exchange with Mr Turner, who told Mr Biden’s lawyer, Abbe Lowell, that he did not understand “what gun shop life is like”.

Naomi Biden was then called to the stand – a surprise move that prosecutors acknowledged they were unaware of ahead of time.

Speaking in mostly simple “yes” or “no” answers, she said she first became aware of her father’s drug use after the death of her uncle, Beau, from cancer in 2015.

“After my uncle died, things got bad,” she said.

She recalled having gone to Los Angeles while he was living with a sober coach in late 2018, saying that she “told him I was so proud of him”.

“He seemed great, he seemed hopeful,” she said of another encounter she had with him in New York City in late October 2018.

During cross-examination from prosecutors, she said that she did not see him at any point use drugs that year, but she admitted she would not know what he would look like under the influence.

In that same October 2018 timeframe, she testified that she had borrowed her father’s vehicle to help her move, saying it was in “good condition” and did not have much in it.

Prosecutors asked her about a 17 October text message she received from her father, sent at 02:00 that day, asking where the keys to his truck were and whether he could get it back.

“Right now?” she responded, and later said: “I’m sorry dad, I really can’t take this.”

She testified that she did not know why her father needed the car at that time, but that he “still seemed good”.

Her testimony stands in contrast to that of Hallie Biden – Hunter Biden’s ex-girlfriend and the widow of his late brother, Beau – who got rid of the gun 11 days after Mr Biden purchased it.

Hallie Biden told the court on Thursday that she discovered Mr Biden’s gun in his truck amid clothes and clutter, including drug paraphernalia.

She said she “panicked” when she found it. She then stuffed it in the leather pouch, wrapped it in a small purple gift bag and disposed of it in a rubbish bin at a local grocery store.

“Are you insane?” he texted, telling her to go back to Janssen’s Market and retrieve the weapon.

It was later found by a man who was rummaging through the refuse for recyclables.

Ms Biden said that she, too, fell into drug addiction after she was introduced to crack cocaine by Mr Biden during their relationship, which began after Beau Biden’s death in 2015, but that she quit using in August 2018.

At court on Friday were US First Lady Jill Biden, along with Mr Biden’s wife Melissa Cohen Biden, who has attended the trial every day so far.

Also there were Valerie Biden and James Biden – the siblings of President Joe Biden.

President Biden has continued with his public duties. On Friday, he gave a speech in France on democracy after meeting Ukrainian President Volodymyr Zelensky.

In an interview with ABC News, Mr Biden said he would accept the outcome of his son’s trial and wouldn’t pardon him if he were convicted.

As the trial got under way this week, Joe Biden said he would not comment as president, but that as a father he felt “boundless love” for his son.

Hunter Biden also faces a trial in California in September on charges of failing to pay $1.4m (£1.1m) in taxes.