The squares marked A and B are the same shade of gray.
The image depicts a checkerboard with light and dark squares, partly shadowed by another object. The optical illusion is that the area labeled A appears to be a darker color than the area labeled B. However, within the context of the two-dimensional image, they are of identical brightness, i.e., they would be printed with identical mixtures of ink, or displayed on a screen with pixels of identical colour. 
A rectangle of the same color has been drawn connecting the two areas of the image.
That the two squares are the same color can be proven using any of the following methods:
Open the illusion in an image editing program and using the eyedropper tool to verify that the colors are the same.
Right-click the image and select "View Image". Now zoom in to the image and hold a finger in front of your face, blocking out the connecting square. Since your finger is a different color and not merely a tone, your eyes will be able to compare A and B individually.
Cut out a cardboard mask. By viewing patches of the squares without the surrounding context, you can remove the effect of the illusion. A piece of cardboard with two circles removed will work as a mask for a computer screen or for a printed piece of paper.
Connect the squares with a rectangle of the same color, as seen in the figure to the right.
Print the image and cut out the squares. Cut out each square along the edges. Remove them. Hold them side by side.
Isolate the squares. Without the surrounding context, the effect of the illusion is dispelled. This can be done by using the eyedropper tool in image editing programs, such as GIMP to sample the values of A & B, and to color in the newly adjacent rectangles using the paint bucket tool.
While being one of the most well-known contrast illusions, there are similar effects which cause two regions of identical color to appear differently depending on context:
The Cornsweet illusion creates a boundary between two identically-shaded regions with a discontinuous gradient, resulting in the opposing sides themselves appearing different.
The Chubb illusion evokes this effect by surrounding zones with others of different, distinct shades, with the relative brightness or darkness of the surrounded area appearing different.
An illusion closely related to the checker shadow illusion, which also relies on using implied visual shadows to seemingly darken a brighter region to the same color as a well-lit dark region, involves two squares placed at an angle, with the darker square being lit and the lighter square at an angle which receives poor light.