The rule was introduced in 2017, after some relationships between prisoners within the units ended in "less than amicable" ways. It was then updated in 2019 and again in 2021.
The most recent version states "prisoners in Kia Marama or Totara Special Treatment Units must not participate in sexual activity, or encourage, pressure or threaten other prisoners to participate in sexual activity".
Any prisoner who breaks the rule would face a penalty such as solitary confinement, expulsion from the rehabilitation programme or the loss of privileges for a certain period of time.
The prison director said the rule aims to manage the risk of prisoners within the treatment units of further offending and to support their rehabilitation in light of the predatory nature of sexual offending.
He said it was about creating a safe environment for the prisoners who go to the units to receive specialised psychological treatment to turn their lives around.
The director believed that sexual relationships between prisoners create a "distraction" from the focus on treatment and rehabilitation and have the potential to break down.
He said what started as a consensual relationship might quickly turn into an alleged assault, which could be extremely damaging to not only the dynamic of the unit but overall friendships within the prison.
The manager of Psychological Services at the Kia Marama and Totara Units said the units house a relatively high number of men who meet the diagnostic criteria for intellectual disability.
Because of this, some prisoners are vulnerable to manipulation and exploitation, she said.
"We have an additional duty of care to them," she said.
"In the absence of access to children and adolescents, men in this environment sometimes substitute their sexual interest, or express their sexual preoccupation towards other men in the unit, typically those they perceive as more vulnerable and who possess characteristics reflective of their preferred victim type."
She said involvement in the programme was voluntary and prisoners were made aware of the rules in an information booklet.
While Smith acknowledged the rule was intended to help with rehabilitation and reintegration into the community for prisoners, he said the rule would encourage secrecy and unprotected sex between the prisoners out of fear of being caught.
Smith also submitted that prison directors should not be allowed to make "discriminatory rules that impose sanctions on prisoners for consensual physical expressions of their sexual orientation".
However, Justice Nation said that while the rule prohibited sexual activity between prisoners in the special treatment units, this was not based on sexual orientation, but rather on safety and rehabilitation.
"The rule is not gender-specific and was imposed to ensure the safety of all prisoners in the Kia Marama and Totara Units.
"The evidence has explained to my satisfaction why the blanket prohibition on sexual activity is necessary and, in particular, why allowance of consensual sexual activity would put prisoners at risk of harm."
Justice Nation declined Smith's application for review of the rule under the Judicial Review Procedure Act 2016 and said director Howson was entitled to costs.