Napoleon seized power in France in a coup and established himself as the dictator of France, taking the title of First Consul. He reorganized the French government and legal system, establishing the Napoleonic Code. Napoleon later declared himself emperor after a plebiscite and expanded French control over much of Europe through military conquest. However, his invasion of Russia in 1812 ended in disaster and led to the collapse of his empire as European nations allied against France. Napoleon's final defeat at the Battle of Waterloo in 1815 marked the end of his rule.