A former civil servant has claimed that Alex Salmond apologised to her for his "unacceptable" behaviour.
The woman, known as Woman F, said the apology came after Mr Salmond told her to sit on a bed, lifted up her skirt and said she was "irresistible".
She denied a suggestion from Mr Salmond's lawyer that there had merely been a "bit of cuddling" between her and the former first minister.
Mr Salmond denies sexually assaulting Woman F with intent to rape.
The incident is alleged to have happened at the first minister's official Bute House residence in Edinburgh in December 2013.
Mr Salmond also denies a further charge that he sexually assaulted the same woman by kissing her on the mouth at Bute House in November or December of the same year.
He has lodged special defences of consent to both of the charges.
The court also heard a claim during Thursday's evidence that rules were introduced in 2013 to prevent women working unaccompanied with Mr Salmond in Bute House.
Woman F told the High Court in Edinburgh that her job as a Scottish government civil servant meant she regularly worked long hours.
She said she had brought some paperwork to Mr Salmond in the Bute House sitting room, which had been very cold because of a problem with the heating.
Woman F claimed that Mr Salmond had suggested they go upstairs to the bedroom, because it was warmer.
She said this did not seem to be an unreasonable suggestion and agreed - but that when they were in the bedroom Mr Salmond started to "drink quite steadily" from a bottle of moutai alcoholic spirit that he had been given as a present from China.
She claimed to have then felt "somewhat uncomfortable" when Mr Salmond asked her to take her boots off, adding: "But it was a request from the first minister, so I complied."
Woman F said it was late at night and she had gathered her papers before attempting to walk to the door.
She said she felt "rising panic" when the first minister told her to "get on the bed", but that "this was very much inside a working environment and culture where you do whatever the first minister asks of you".
The witness said she sat "primly" on the bed and could not remember exactly what happened in the first few seconds, but then "the first minister was lying on top of me, he put his hands under the skirt of my dress, ran them over my thighs and my bottom and he was rubbing his hands over the bodice of my dress and over my breasts.
"He was kissing me around my face and dress, haphazardly like someone who had been drinking quite heavily, and was murmuring something like 'you're irresistible'."
Woman F said she "absolutely did not" give Mr Salmond any invitation to do this, and had repeatedly been telling him that "this wasn't a good idea" and that she needed to leave.
She said she had felt a "mix of panic and disbelief that it could be happening. I knew I had to stop this, to get away, but how on earth to actually achieve that?
"It seemed very clear that he wasn't going to stop unless I could in some way bring things to a stop. I felt he was going to continue in the same vein and there would be a progression in the sense of trying to remove some of my clothes or taking things further, pushing things further.
"I thought he was going to try to remove my tights and my underwear and he would be pushing the encounter physically further."
She said Mr Salmond had either eventually stopped or had shifted his weight. She managed to get up from the bed and "said goodnight" to him.
She said she had been "extremely upset" on her walk home, and texted or emailed a colleague to say "that's an evening I'll need to forget".
The witness said she subsequently met the colleague, who told her it "could be a crime" and advised her to contact her line manager.
She said this had led to one of Mr Salmond's special advisers speaking to the first minister and suggesting that he apologise to her.
Woman F claimed that, some days later, she had a meeting with Mr Salmond at his office in the Scottish Parliament during which "he told me he was sorry for what had happened, that it had been unacceptable, that he had been drinking more than usual - not just that night, but in general due to stress.
"He said he respected me and wanted to keep working together and apologised. I accepted the apology, confirmed we would keep working together.
"I remained in the post and did not experience any other behaviour from the first minister that I considered inappropriate in the rest of my time in that post.
"I told my husband in general terms. I still have not told anyone else in my family."
The court was told of an email written by Woman F shortly after midnight on the night that the assault is alleged to have happened, in which she referred to "thanking the Chinese" for the moutai and said there may be "one or two headaches in the morning".
Under cross-examination from Mr Salmond's defence lawyer, Gordon Jackson QC, she denied that this meant that she had also been drinking heavily, insisting that she had only a "very little" of the spirit.
She said the email had been intended to warn a colleague that Mr Salmond was likely to be hungover in the morning, adding: "The first minister liked to encourage staff to drink with him. I personally didn't like to drink much in his company."
Mr Jackson described Mr Salmond as a "tactile human being", and put it to the witness: "What I'm saying happened is there was a bit of cuddling between the two of you, and you ended up lying side by side on the bed. It was described to me as a sleepy cuddle."
Woman F replied: "Absolutely not. I refute any suggestion that I cuddled the first minister."
She also said that it would have been "unthinkable" to have contacted the police at the time because of the "political context".
She added: "Our job involved protecting the first minister and his reputation, and in the run up to the (independence) referendum anything that took that incident into the public sphere risked influencing the outcome of the referendum. That seemed unacceptable."
The court later heard from Woman G, who said she had previously worked with Mr Salmond. She alleged that he had once "smacked my buttocks" when she was leaving a dinner at the Ubiquitous Chip restaurant in Glasgow in 2012, which she said had felt "demeaning, like I was a plaything to him".
She said she had mentioned it to a colleague but did not take it any further as: "He was my boss, I only existed in the job because of him and he just happened to be the most powerful person in the country."
When it was suggested by Mr Jackson that the smack had been "playful", the witness said she had considered it to be "extremely inappropriate".
Woman G also alleged that Mr Salmond invited her to sit next to him on a two-seater couch in Bute House in April of the following year.
She claimed Mr Salmond had been drinking "a good deal", and had made inappropriate remarks before putting his arm round her and attempting to kiss her.
The woman said she made her excuses and left, before messaging a friend to say that Mr Salmond had been: "Out of order, he has been inappropriate, I'm not going back in tomorrow morning."
She went on to claim that a decision was subsequently taken that women should not be allowed to work with Mr Salmond unaccompanied.
The final witness of the day was Woman G's mother, who said her daughter had told her that she knew something about Alex Salmond that could "change everything".
Mr Salmond has pled not guilty to 14 charges of sexual assault against a total of 10 women, all of which are alleged to have happened when he was serving as Scotland's first minister and the leader of the SNP.