In 1822 Edward Stanley, as he was then, was elected to Parliament in the rotten borough of Stockbridge (see Stockbridge (UK Parliament constituency)) as a Whig, the traditional party of his family. In 1824, however, he alienated some of his Whig colleagues by voting against Joseph Hume's motion for an investigation into the established Protestant Church of Ireland. He lost his seat in 1826. When the Whigs returned to power in 1830, Stanley became Chief Secretary for Ireland in Lord Grey's Government, and entered the Cabinet in 1831. As Chief Secretary Stanley pursued a series of coercive measures which frequently brought him into conflict with the Lord Lieutenant of Ireland, Lord Anglesey. In October 1831, Stanley wrote a letter, the Stanley Letter, to the Duke of Leinster establishing the system of National Education in Ireland. This letter remains today the legal basis for the predominant form of primary education in Ireland. In 1833, Stanley moved up to the more important position of Secretary of State for War and the Colonies, overseeing the passage of the Abolition of Slavery Bill.