KABUL, Afghanistan — Shamsea Alizada’s story could so easily have ended when she was just 15.

A coal miner’s daughter whose family had moved all around Afghanistan seeking safety and the chance for her and her siblings to get a good education, Ms. Alizada was among the lucky who evaded the suicide bombing that killed dozens of her fellow students at a Kabul tutoring center two years ago.

But if it was luck that saved Ms. Alizada, now 17, it was resilience and hard work that made her a national inspiration, when it was announced on television on Thursday that she had achieved the highest score out of nearly 200,000 students on Afghanistan’s national university entrance exam. Her mother saw it and gave her the happy news personally.

“I thought she was kidding. But when I entered the room, I saw the brightest smile on my mother’s face,” Ms. Alizada said in an interview. “I have seen her smiling, but yesterday’s smile was something else. Her smile was a gift and made my day; it was better than gaining the highest score in the country.”

A generation ago, she would probably never have gotten the chance. Under Taliban rule, girls were prevented from going to school. It is the success of Ms. Alizada and young Afghans like her that have provided one of the few bright spots in the decades of war and unrealized Western goals since: More girls are not only going to school, they are also starting to translate that into social mobility.