Virtual Reality is an incipient technology that is proving very useful for training different skills. Our hypothesis is that it is possible to design virtual reality learning activities that can help students to develop their spatial ability. To prove the hypothesis, we have conducted an experiment consisting of training the students using an on-purpose learning activity based on a virtual reality application and assessing the possible improvement of the students' spatial ability through a widely accepted spatial visualization test. The learning activity consists of a virtual environment where some simple polyhedral shapes are shown and manipulated by moving, rotating and scaling them. The students participating in the experiment are divided into a control and an experimental group, carrying out the same learning activity with the only difference of the device used for the interaction: a traditional computer with screen, keyboard and mouse for the control group, and virtual reality goggles with a smartphone for the experimental group. To assess the experience, all the students have completed a spatial visualization test twice: just before performing the activities and four weeks later, once all the activities were performed. Specifically, we have used the well-known and widely used Purdue Spatial Visualization Test-Rotation (PSVT-R), designed to test rotational visualization ability. The results of the test show that there is an improvement in the test results for both groups, but the improvement is significantly higher in the case of the experimental group. The conclusion is that the virtual reality learning activities have shown to improve the spatial ability of the experimental group.