Battle of Rivoli, relieving General Joubert when the latter was attacked by the Austrian general Jozsef Alvinczi. His power of work, accuracy and quick comprehension, combined with his long and varied experience and his complete mastery of detail, made Berthier the ideal chief of staff. In this capacity, Berthier was Napoleon's most valued assistant for the rest of his career. Berthier accompanied Napoleon throughout the campaign of 1796, and was left in charge of the army after the Treaty of Campo Formio. He was in this post in 1798 when he entered Italy, invaded the Vatican, organized the Roman Republic, and took Pope Pius VI prisoner. Berthier supervised the Pope’s relocation to Valence, where, after a tortuous journey, Pius died. The death of the Pope dealt a major blow to the Vatican's political power which, however, did not prove as ephemeral as that of the First French Empire. After this, Berthier joined his chief in Egypt, serving there until Napoleon's return. He assisted in the Coup of 18 Brumaire (9 November 1799), afterwards becoming Minister of War for a time. During the Battle of Marengo, Berthier was the nominal head of the Army of Reserve, but the first consul accompanied the army and he acted in reality, as always, as chief of staff to Napoleon. Lest one think that this was a relatively safe job, a contemporary subordinate staff officer, Brossier, reports that at the Battle of Marengo: At the close of the campaign, he was employed in civil and diplomatic business. This included a mission to Spain in August 1800, which resulted in the retrocession of Louisiana to France by the Treaty of San Ildefonso on 1 October 1800, and led to the Louisiana Purchase. When Napoleon became emperor, Berthier was at once made a Marshal of the Empire. He took part in the campaigns of Austerlitz, Jena, and Friedland. He was made Duke of Valangin in 1806 and Vice-Constable of the Empire in 1807. When Napoleon deposed King Frederick William III of Prussia from the principality of Neuchâtel, Berthier was appointed its ruler. This lasted until 1814 and also brought him the title of sovereign prince in 1806. In 1808, he served in the Peninsular War, and in 1809, served in the Austrian theatre during the War of the Fifth Coalition, after which he was given the title of Prince of Wagram. He was with Napoleon in Russia