A transgender teenager has killed himself after explaining in a heartwrenching message: 'I'm a prisoner of my own body.'

The death of Riley Matthew Moscatel, 17, has devastated friends and relatives, who said they had accepted his decision to drop his birth name, 'Jessica', in favor of 'Riley' in the spring.

On Monday afternoon, surveillance cameras recorded the high school senior stepping out in front of an Amtrak train near to his home in Croydon, Pennsylvania, ending his life.

'My mirror reflects Jessica, my heart and mind say Riley,' he posted in an Instagram picture just before. 'You see me as the happiest person in school, I'm a prisoner of my own body.

Proud: Riley Matthew Moscatel, 17, was open about his transgender identity and shared this image to Instagram showing how far he had come since freshman year, when he was still known as 'Jessica'

'You see me having a successful future, I can't see me at my graduation day. I say my hearts beating, but it's beating slower and slower each day... I've had enough.'

The lengthy message, which also apologized to his parents for not being the daughter they had wanted, was written on the backdrop of a train track and posted to his account.

Shocked friends said that he had apparently got through childhood depression but still struggled with his female body, the Philadelphia Inquirer reported.

' Everyone supported him,' said Kate Cimino, who had been in a relationship with Riley.

But he 'still really wasn't a guy physically', she explained. 'Even though everyone showed support and called him Riley, it didn't match up to what he felt of himself.'

Struggle: Before he killed himself on Monday, Riley posted this message to Instagram detailing his pain

Friends said that he had been researching hormone treatments that he hoped to start when he turned 18. His parents had also bought him a breast binder.

In June he wrote beneath a photograph of himself on Facebook: 'I just wanna wake up to my actual body, not to what leftovers I've been given.'

Speaking to The Trentonian, Riley's family said they were 100 per cent supportive of their son - but admitted that they were so used to calling him their daughter that they sometimes slipped up.

'We knew that it was important to her,' his dad Rich Moscatel said of Riley's male identity. 'If it was important to her, it was important to us whether we understood it or not.'

His mother Kristine Moscatel said he had started calling himself Riley a year ago.

'We went from her thinking she was a lesbian, to bisexual, to finally transgender,' she said. 'She didn’t know what she wanted to try and fit into.'

Support: Riley had been dating Kate Cimino, who said people's support could not change his opinion of himself

Missed: Surveillance footage captured Riley walking in front of a train on Monday afternoon, police said

When he spoke about his identity to his parents, Kristine Moscatel said she drove him to a local high school to take part in its Gay-Straight Alliance.

The teenager also had the support of his teachers at Bucks County Technical High School, where other transgender and gay students attend.

Kevin Gentilcore, supervisor of Pupil Personnel Services, said the boy's teachers were devastated.

Rates of suicide and suicide attempts are much higher among transgender people - as much as 41 per cent, according to one survey, which is nearly nine times the national average.

Arnold Grossman, a New York University professor, told the Inquirer the suicide attempts often came from feelings of not belonging, burdening family members, and seeing no way out of the situation.

For confidential support in the U.S., call the National suicide Prevention Line on 1-800-273-825