TITLE: Does the fibres being equal dimensional imply flatness?
QUESTION [9 upvotes]: Let $f: Y \to X$ be a morphism of varieties (proper if necessary). 
I read from a paper that if all the fibres of $f$ are of the same dimension then $f$ is flat. This seems skeptical for me, and I was wondering more conditions are need to have the flatness

REPLY [15 votes]: This is true provided that the source is Cohen--Macaulay (e.g. regular) and the base is regular.  This is sometimes called miracle flatness.  (It can be found  as Thm. 23.1 of Matsumura's CRT.)
It generalizes the fact that a non-constant map from a reduced curve to a smooth curve is necessarily flat.
(In the case when the fibre dimension is zero, it is related to the Auslander--Buchsbaum theorem, which says that a f.g. faithful Cohen--Macaulay module over a regular local ring is necessarily free.)
Added: As Georges Elencwajg points out in a comment below, in the context of miracle flatness I should require that we are working with locally finite type schemes over a field.