Her services in favour of France were rewarded in 1699 by a pension, which her problematic financial situation made necessary. When Philippe of France, Duke of Anjou, grandson of the French king, was declared heir by the will of Charles II, she took an active part in arranging his marriage with Princess Maria Luisa of Savoy, a daughter of Victor Amadeus II, Duke of Savoy. Her ambition was to secure the post of "camarera mayor de palacio" (head of the queen's household) to the young queen, a child of barely thirteen. By quiet diplomacy and with the help of Madame de Maintenon, she succeeded, and in 1701, she accompanied the young queen to Spain. Until 1714, the year of the death of the queen, she was the most powerful person in the country. Her functions in relation to the king and queen were almost those of a nurse. Her letters show that she had to put them to bed at night, and get them up in the morning. She gives a most amusing description of her embarrassments when she had to enter the royal bedroom, laden with articles of clothing and furniture. But if the "camarera mayor de palacio" did the work of a domestic servant, it was for a serious political purpose. She was expected to look after French interests in the palace and to manage the Spanish nobles, many of whom were of the Austrian party, and who were generally opposed to foreign ways or to interference with the elaborate etiquette of the Spanish court. Madame des Ursins was resolved not to be a mere agent of Versailles. During the first period of her tenure, she was in frequent conflict with the French ambassadors, who claimed the right to attend the privy council and to direct the government. Madame des Ursins urged that the young king should rely as much as possible on his Spanish subjects. In 1704, her enemies at the French court secured her recall, but she still had the support of Madame de Maintenon, and her own tact enabled her to placate Louis XIV. In 1705, she returned to Spain with a free hand, and with what was practically the power to name her own ministry. During the worst times of the War of the Spanish Succession, she was the real head of the Bourbon party and was well aided by Princess Maria Luisa of Savoy, the spirited young queen of Philip V. She did not hesitate to quarrel even with so powerful a personage as Cardinal Luis de Portocarrero, Archbishop of Toledo, when he proved hostile.