Kevin Harvick had to battle Brad Keselowski for the victory in a final lap thriller at Richmond.