“Prisoners” is episode three of season two of Stargate SG-1.
SG-1 are on what appears to be an empty planet and are about to leave when a strange man approaches them. They help him, only to be taken into custody by someone unseen. They are accused and found guilty of crimes that result in them being sentenced to life imprisonment in an underground area on another planet that is reached only through the stargate. Their helping of the strange man was really not appreciated.
SG-1 try to escape from the prison whilst SGC tries a diplomatic solution to the problem, with General Hammond going there in person to negotiate.
Bit of a change in speed from the recent Apophis episodes, as this lacks the potentially Earth-ending feel of those ones.