Robert Jones, 46, from Merthyr Tydfil, has been found guilty of attempted murder for stabbing his girlfriend's son.
The Crown Prosecution Service (CPS) says Jones has paranoid schizophrenia and is being sent to a secure hospital with no time limit.
It says Jones heard voices, which told him to stab his girlfriend's son, Andrew Burvill, 35 of Brecon.
Jones stabbed Mr Burvill 18 times in March earlier this year. The CPS says Mr Burvill suffered two wounds to the head, a wound to the neck, shoulders, three wounds to the chest, the leg and hands. Mr Burvill survived the attack.