Nobel laureate Malala Yousafzai has been appointed a UN Messenger of Peace to promote girls' education, more than four years after a Taliban gunman shot her in the head.

At 19, Yousafzai is the youngest Messenger of Peace, the highest honour given by the UN for an initial period of two years.

She was also the youngest person to win the Nobel peace prize in 2014 when she was 17.

The Pakistani education activist came to prominence when she was shot in the head in 2012 as she was leaving school in Pakistan's Swat valley, northwest of the country's capital, Islamabad.

She was targeted for her campaign against efforts by the Taliban to deny women education.

"You are not only a hero, but you are a very committed and generous person," UN Secretary-General Antonio Guterres told Yousafzai.

Other current Messengers of Peace include actors Leonardo di Caprio (climate change), Charlize Theron (prevention of HIV and elimination of violence against women), and Michael Douglas (disarmament).

Yousafzai has become a regular speaker on the global stage and visited refugee camps in Rwanda and Kenya last July to highlight the plight of refugee girls from Burundi and Somalia.

READ MORE: Profile - Malala Yousafzai

"Now this is a new life, this is a second life and it is for the purpose of education.

"The extremists tried all their best to stop me, they tried to kill me and they didn't succeed," Yousafzai said on Monday.

Girls' education champion. Nobel Prize winner. Global inspiration. And now youngest UN Messenger of Peace. Congratulations Malala Yousafzai! pic.twitter.com/WFeej6B0eX — António Guterres (@antonioguterres) April 10, 2017

In January 2009, Yousafzai began to keep a diary for the BBC’s Urdu service, in which she detailed how she had been affected by the Taliban’s rule, and what life was like for her and her peers under them.

She wrote then under the pen name "Gul Makai", the name of the heroine from a local Pashtun folk tale.

Swat valley was under the control of the local chapter of the Tehreek-e-Taliban Pakistan (TTP) during that time. The TTP-Swat enforced a strict interpretation of Islam in the valley, ruling with an iron fist.

One of its many edicts enforced a complete ban on women’s education.

Yousafzai now lives in the UK, where she received medical treatment following her shooting.