Iraqi and U.S. officials came closer to a long-term security deal Thursday by agreeing to a withdrawal of American forces by the end of 2011, though other sticking points remained such as immunity for U.S. troops in Iraq.