In 1923 anotherpronunciamientotook place: general PdeRivera got to power with the consent of the king. Public disorder was the main problem for people at the time. The system did not seem to work any longer. Primo had been stationed in Catalonya as captain general and was well received by the people there. They thought he could bring calm and peace in such troubled times.His1st idea was to hold power for a limited period of time to try to regenerate the system. Then he would give the reins of power back again. It did not happen that way. He stood there for longer than promised and became unpopular. He also tried to start a sort of political party, the Unión Patriótica.His dictatorship can be divided into two: Military Directory(1923-1925) andCivil Directory(1925-1930). In his first years he achieved a great success. Along with the French the Spanish Army defeated the Moroccan rebel Abd-el-Krim at the Alhucemas landing. The Moroccan question seemed to be over. In the second stage of his government lots of things were made: a number of public works, the creation of state regulatory agencies, exports were on the rise in the early years, the creation of a state-owned petroleum company. The 1929 crisis was also felt in Spain: the currency, the peseta, lost value. The dictator lost the support of the army and the king and finally resigned in 1930. Berenguer and Aznar were the following heads of government, but things did not go smoothly. In the summer of 1930 different Republican supporters met in San Sebastián to discuss about what could be done to favour the setting up of the republic (San Sebastian Pact). In December an attempt took place in Jaca, but it failed. The municipal elections held on April 12 1931 gave the victory to Republican parties in most towns. Having lost the affection of his people and to avoid any bloodshed, Alfonso XIII left Spain. On April 14 1931 the Second Republic was proclaimed.