Ward allegedly pinned the woman down, groped her breasts and digitally penetrated her against her wishes.
She alleges Ward said, "Shh just let it happen", while she struggled against him.
The alleged attack only stopped when the man giving evidence, with whom the woman had been in a relationship, entered the cabin, the court heard.
The man, who has name suppression to protect the identity of the alleged victim, appeared via video link.
The location where he appeared from is suppressed.
In response to questions by Crown prosecutor Alysha Mcclintock, he said he and the woman were in a "casual sexual relationship".
On the night of the alleged attack, he said he had been drinking in a group with the woman and other Navy friends.
They went to a bar in Wellington, and he was "quite intoxicated".
After visiting a strip club, he returned to a different ship before going to the woman's ship and into her cabin.
"I think [the woman] was in her bed and as soon as I went in she got out of her bed and I started to kiss her," he said.
He could not recall where Ward was, but did remember him leaning on a desk in the room at some stage.
"I was concentrating more on [the woman].
"I remember him standing up against the desk and that's about the only flash I have of him being there.
"We had intercourse. From memory it was on the couch and on the floor."
Under cross-examination by Ward's lawyer, Anthony Rogers, the man said he did not recall Ward being in the woman's bunk.
He did not recall any dialogue with Ward, or the woman "moaning in pleasure" as a result of her interaction with Ward.
He could not recall their state of dress or asking Ward to join the pair for "family styles" - a slang term for group sex.
The trial continues.