We propose an online algorithm based on local sparse representation for robust object tracking. Local image patches of a target object are represented by their sparse codes with an over-complete dictionary constructed online, and a classifier is learned to discriminate the target from the background. To alleviate the visual drift problem often encountered in object tracking, a two-stage algorithm is proposed to exploit both the ground truth information of the first frame and observations obtained online. Different from recent discriminative tracking methods that use a pool of features or a set of boosted classifiers, the proposed algorithm learns sparse codes and a linear classifier directly from raw image patches. In contrast to recent sparse representation based tracking methods which encode holistic object appearance within a generative framework, the proposed algorithm employs a discrimination formulation which facilitates the tracking task in complex environments. Experiments on challenging sequences with evaluation of the state-of-the-art methods show effectiveness of the proposed algorithm.