WASHINGTON — Hillary Clinton held back tears on Wednesday as she asked her supporters not to lose heart after a crushing election loss and to continue working for a better country.

“I will admit coming here tonight wasn’t the easiest thing for me,” Mrs. Clinton said at a gala for the Children’s Defense Fund, where she worked as a young law student. “There have been a few times this past week when all I wanted to do is just to curl up with a good book, or our dogs, and never leave the house again.”

In her first public remarks since conceding to President-elect Donald J. Trump last week, Mrs. Clinton told the crowd she was struggling to recover from an unexpected defeat that she said had left nonwhite children and vulnerable people across the nation afraid.

“I believe the measure of any society is how we treat our children, and as we move forward into a new and in many ways uncertain future, that must be the test for America and ourselves,” Mrs. Clinton said in a 20-minute speech. “No child should be afraid to go to school because they’re Latino, or African-American, or Muslim, or because they have a disability.”