Amelia Saunders was a pupil at Crosfields School, Reading, where the Talbot Memorial Garden was created. She died in January 2013.
A cherry tree was planted at the site in memory of her. The garden also features a small bridge and a pergola.
It aims to offer pupils "peace and relaxation", a spokeswoman said.
During her visit, a bouquet of flowers was presented to the Princess of York by two pupils, including Amelia's four-year-old sister Charlotte.
A spokeswoman at the school said the garden, created by local designer Clare Olof, was a legacy left by the school's first chairman of governors, Clifford Talbot.
"He gave a sum of money to develop an outside area to offer children peace and relaxation," she said.
"It seemed a fitting tribute to dedicate it to Amelia."
Amelia was diagnosed with an inoperable brain tumour in February 2012.
She died at Naomi House Children's Hospice in Sutton Scotney, Hampshire, and a memorial ceremony was held in Winchester.
A garden created in memory of a four-year-old girl who died from an inoperable brain tumour has been officially opened by Princess Beatrice.