A tile layer charged with attacking a man at a Paola residence on Thursday was released from custody on Friday after his arrest was declared invalid.
Mohammed Hamza, a 37-year-old Libyan national, was charged with attempting to place the life of his alleged victim in manifest danger but willingly stopped the attack.
He was also charged with causing grievous bodily harm and wilfully breaching the public peace.
Before he pleaded to the charges, his lawyers contested the validity of the arrest.
Court was told that at around 9.30am on Thursday, a man entered the Paola police station wearing a blood-stained top and with blood on his hands and face.
He sat down in a chair and an officer asked whether he needed medical help.
But the man - later identified as Mohammed - replied: "not me. Someone else".
The blood was not his but someone else's with whom he had just argued, the man added.
Meanwhile, a second report came in about a man who needed help.
He had been assaulted with a sledgehammer and a sharp tile layer's tool.
The victim told the police that he had been attacked by a "certain Mohammed".
The constable at the police station, acting under instructions of a sergeant, informed Mohammed that he was under arrest, explained prosecuting Inspector Keith Rizzo.
The duty magistrate was informed of the arrest at 11am.
The defence pounced on that information to challenge the validity of the arrest citing article 355AD(i) of the Criminal Code.
"The law speaks clearly," argued lawyer Jacob Magri.
In case of voluntary attendance at a police station, the arrest must be authorised by an inspector and the duty magistrate must be informed "immediately", he added.
The prosecuting inspector said he had been told of the arrest "within minutes".
But after hearing further submissions, the court, presided over by Magistrate Leonard Caruana, declared that the arrest was not in line with the law.
The accused was released from arrest.
He then pleaded not guilty.
The court upheld a request for a protection order in favour of the victim.
In view of the gravity of the charges, the fact that the victim was still to testify and the risk of absconding, the court upheld the prosecution's request for conditions to be imposed on the accused, although there was no bail.
The court ordered the accused not to approach any prosecution witnesses, to attend all court sittings, not to abscond and to bind himself under a personal guarantee of €3,000.
AG lawyer Kaylie Bonnet and Inspector Keith Rizzo prosecuted.
Lawyers Alfred Abela, Arthur Azzopardi, Jacob Magri and Rebecca Mercieca were defence counsel.