Aaron Beltran allegedly made the agreement with Oxford University graduate Andrew Breach who agreed to pay the accused a fee depending on how many times the amputation video was shared on social media. The fee ranged from £173 (€200) to a maximum of £2,164 (€2,500).
Beltran faces up to four years and six months if he is found guilty of wounding. He denies any wrongdoing.
The extraordinary deal which led to the amputation in March 2019 was outlined by prosecutor Asunción Losada at a court in Zaragoza, eastern Spain.
A police officer told the court he found Mr Breach, 35, who worked at a language academy in Zaragoza, bleeding heavily in the city centre.
The officer, who was not named, said he went to the house the Briton shared with Mr Beltran where the accused told him that the teacher’s penis had been severed and dumped in a rubbish bag.
Another officer said: “When interviewing the victim in hospital he told us the accused cut off his penis. Andrew said he did not feel 100 per cent a man and wanted to get rid of his penis.
“He agreed a deal with the accused to pay him €200 which would depend on how many views the video of the amputation received on You Tube. It was done on the basis of hits.”
The officer, who was not named, said the British teacher subscribed to a website and was looking for someone to film him mutilating himself.
Prosecutors admit the amputation was consensual but argue that does not exempt the Spaniard set to stand trial from criminal responsibility.
Surgeons were able to reattach the penis and it is fully functioning.
The teacher spent three weeks in hospital after the incident before returning to Britain.
Mr Breach told the court that he had cut off his own penis, contradicting an earlier sworn statement in which he said Beltran carried out the amputation.
“I cut off my own penis. I was unwell. It was myself,” he said.
Mr Breach said he made a statement to police that Beltran had sliced off his penis because he felt under pressure from officers, a claim police denied in court.
Prosecutors have accepted Mr Breach, who describes himself as a graduate in English language and literature, suffers from gender dysphoria.
His penis was successfully reattached during an operation and is understood to be functioning properly.