Former Democratic presidential nominee Hillary Clinton penned a personal letter to an 8-year-old girl who lost her race for class president to a boy.

Clinton wrote to console Martha Kennedy Morales after the third-grader lost the election by a single vote, according to The Washington Post, which confirmed the letter's authenticity with a Clinton spokesman.

"As I know too well, it's not easy when you stand up and put yourself in contention for a role that's only been sought by boys," Clinton wrote in the letter.

Morales's father posted updates about his daughter's campaign on Facebook, which caught the attention of someone close to Clinton.

Morales said she lost her election to a popular fourth-grade boy in her mixed-grade class at Friends Community School, a private Quaker school in Maryland. She was named vice president after six ballots were found to be filled out incorrectly, losing a second election by one vote.

"While I know you may have been disappointed that you did not win President, I am so proud of you for deciding to run in the first place," Clinton wrote to Morales. "The most important thing is that you fought for what you believed in, and that is always worth it."

"As you continue to learn and grow in the years ahead, never stop standing up for what is right and seeking opportunities to be a leader, and know that I am cheering you on for a future of great success," the former first lady, senator and secretary of State wrote.

The 8-year-old told the Post that she was "very surprised" to get a letter from Clinton, who was the first woman to be a major party's presidential nominee.