Malala, 16, was shot in Pakistan last October after campaigning for the right of girls to go to school without fear, in a part of the country where Islamic fundamentalists were trying to impose a strict form of Sharia law.
Surgeons who treated her said she came within inches of death when the bullet grazed her brain in the school bus attack.
The schoolgirl, who was treated in Birmingham after the attack and now lives in the city, was a guest at a reception for commonwealth, youth and education hosted by the Queen and Duke of Edinburgh, and was selected as one of a handful of people to be presented to the royals.
She gave the Queen a copy of her book, I Am Malala, which the monarch accepted, adding: "That's very kind of you. Thank you very much indeed."
Speaking to the Queen, she said of her invite to the palace: "It is not just an invitation, it is an honour for me, and I hope we all work together for the education of every child."