This paper presents a novel scheme for dynamically recovering a background image from consecutive frames of a video sequence based on spatial and temporal continuities. The proposed background subtraction algorithm applies a boundary-level spatial continuity constraint in order to detect and correct ghosting, which corresponds to incorrectly classified foreground regions due to fast moving objects. A pixel-level spatial continuity metric that effectively recovers regions with partial ghosting problems is also proposed in this paper together with a selective application of a temporal continuity metric in order to prevent strong pixel transitions in the background from hindering the background recovery process. The proposed method can also be applied successfully to sequences with deformable foreground objects and non-uniform motion. Simulation results show that the extracted background, when used for foreground detection, results in a higher performance in terms of recall and precision as compared to existing popular schemes.