His first period of incarceration was short, apparently thanks to the intervention of Teixeira de Queiroz, an influential judge and, coincidentally, father of the renowned José Maria de Eça de Queiroz. During his second and longer incarceration he wrote what most consider to be his best and most characteristic work "Amor de Perdição". Later this phase of his life would also inspire him to write his "Memórias do Cárcere" (literally "Memories of Prison"), in which he describes the meanders of the then miserable and overcrowded prison of Relação, at the centre of Oporto, intertwined with intimate ramblings of the imagination and biographical fragments.