The yacht, named the Lady Anastasia, is a 156-foot-long boat with five cabins and is owned by Alexander Mijeev, a former head of the Russian Helicopter Corporation.
In 2016, he took over Rostec, a Russian state-owned weapons supplier.
The sailor, who has not been named, allegedly opened the ship’s valves causing it to partially sink, reported Spain’s Balearic Island newspaper Ultima Hora on Sunday.
He opened one valve in the engine room and a second where the crew lives and allegedly asked three other crew members, also Ukrainians, to abandon the ship.
He also turned off the fuel valves and switched off the electricity on the ship.
Later when the civil guards came to arrest him, he said: “The owner of this ship is a criminal who makes his living selling weapons and now they kill Ukrainians.”
Since Russia invaded Ukraine last Thursday in a full-scale military operation, the country has been bombarded with explosions and missiles as thousands have been forced to flee their homes to escape the war.
In court, the sailor, who has been working for the ship for a decade said he blamed Mr Mijeev for producing weapons used to attack Ukraine.
He said he had seen news on television about how a Russian cruise missile hit a block of flats and assumed that the missile had been made by his boss.
“The warhead did not explode, but more than five floors were still destroyed,” he said in his statement in court.
The sailor recalled living in a similar apartment in Kyiv and sought to take revenge on his boss.
He said he only meant to cause material harm to Mr Mijeev and it was not personal.
The sailor has been charged but released by the judge.