Gamma-ray burst (GRB) afterglows have provided important clues to the nature of these massive explosive events, providing direct information on the nearby environment and indirect information on the central engine that powers the burst. We report the discovery of two bright X-ray flares in GRB afterglows, including a giant flare comparable in total energy to the burst itself, each peaking minutes after the burst. These strong, rapid X-ray flares imply that the central engines of the bursts have long periods of activity, with strong internal shocks continuing for hundreds of seconds after the gamma-ray emission has ended.