Flatland is narrated by A Square, a professional gentleman in a two-dimensional world where all beings are geometrical figures moving on a plane. In this world every figure looks identical from within, a straight line, so inhabitants recognize one another by touch (feeling angles) or by trained sight discrimination. Social rank is determined strictly by the number of sides: Straight Lines (women) at the bottom, then Isosceles Triangles (soldiers and laborers), Equilateral Triangles (tradesmen), Squares and Pentagons (professional men), Hexagons and above (nobility), and finally Circles (the priestly class), who govern absolutely.
Part I describes Flatland society in detail: its climate, its architecture, its methods of recognition, and its rigid class rules. Children are born with one more side than their father. Irregular figures, those whose sides are unequal, are treated as criminals and may be executed. The women of Flatland, being mere line-segments with no angle to feel and dangerously sharp endpoints, are kept in constant submission by law and custom, required to cry aloud as they move to warn others of their approach.
Part II opens with the Square's encounter, on New Year's Eve of 1999, with a mysterious visitor who appears as a circle that changes size without explanation. The visitor is a Sphere from Spaceland, a being of three dimensions. When the Sphere tries to explain the Third Dimension in words, the Square cannot grasp it; the concept of 'upward, not northward' makes no sense to a creature who has no eye on his interior. Only when the Sphere lifts the Square bodily out of Flatland and into Space does the Square suddenly see the insides of all Flatland houses and inhabitants laid open below him.
In Spaceland the Square is converted and elated, and immediately pushes further, arguing by analogy that if a moving Square generates a Cube, a moving Cube must generate a four-dimensional figure, and so on without limit. The Sphere, who cannot conceive of a Fourth Dimension, becomes annoyed and flings the Square back to Flatland. There the Square attempts to preach the Gospel of Three Dimensions: first to his Grandson (who laughs), then through a treatise, and finally in a speech before the Local Speculative Society. He is immediately arrested.
The book closes with the Square serving a sentence of perpetual imprisonment. Seven years on, his own brother, who witnessed the Sphere in the Council Chamber, still cannot believe in a Third Dimension. The Square writes his memoir in the hope that it will reach minds in 'Some Dimension' and stir up a spirit of rebellion against any doctrine that limits the number of dimensions to a fixed number. His final pages waver between aspiration and doubt, unsure whether the Cube and the Sphere are realities or the products of a diseased imagination.