The Pope had bestowed the title of 'Most Catholic Monarchs' on Ferdinand and Isabella, the couple that united Spain under the cross. Charles V had inherited this title from his parents, and Philip II likewise inherited it from Charles. As the foremost Christian ruler in Europe, the Papacy needed Philip to organize and fund military campaigns against the Ottoman Turk and Protestant heretic. The main sphere of conflict between the Turks and Christianity was in the Mediteranean, which meant the Papacy was motivated not just by spiritual concerns but temporal ones also - the Papal states, in the heartland of Italy, were themselves at risk from the infidel.
As opposed to his contemporary Elizabeth I of England (who famously said she had no wish for "a window into men's souls"), Philip II was a most devout and pious Catholic, as he informed a disgruntled Pope Pius V -
"Rather than suffer the least damage to religion and the service of God, I would lose all my states and a hundred lives if I had them; for I do not propose nor desire to be the ruler of heretics."
While one is right to detect a certain exageration in this letter to the Pope (more on Papal relations, particulary Sixtus V, below), Philip knew that as the most powerful ruler in Christendom his job was to stamp down on heresy and resist the ebb of the infidel. Doing so also afforded him a prestige, especially when the Papacy was behind him - what higher legitimacy could there be than that granted by the Curia?
Philip and the Spanish Church
Men said there was no Pope in Spain, and many historians are of the opinion that Philip's control over the Spanish Church was more complete than the ruler of any other country, even Protestant ones. He had the power to make all minor appointments in the Church, take the revenue from vacant sees, and in 1572 prevented anyone in the Churches of Castile, Aragon (Castile and Aragon were the two halves of Spain, see the excellent write-ups in their nodes by Excaliber for history) or the Inquisition appealing to the Papacy. He could also from this point onwards choose whether to publish papal bulls within his realms (before 1572, he had this power only in Naples.) When the Pope issued a bull excommunicating anyone who attended bull fighting, Philip merely ignored it.
The Spanish Church was rotten in the second quarter of the 16th century, and on the date of Philip's coronation in desperate need of reform. The usual problems of the Church in this time were prominent - simony, nepotism, venality, pluralism, absenteeism. Priests were poorly paid and often unable to perform their duties, while higher clergy enjoyed some of the highest incomes in the Empire. However, unlike in other dominions, heresy had not taken root in the soul of the Spaniards - the Inquisition had been suppressing heretical writings and heresy itself for so long that the Spanish didn't really come into contact with it. What was present, however, was a fair amount of pagan superstition and ritual - often intertwined with Catholic rites.
The Inquisition had been so busy with the problem of Jews and Moors - who, upon their forced conversion, were referred to as conversos and Moriscos respectively - that it had neglected the spiritual development of the majority of the Spanish laity. Thus Christian rituals and rites had degenerated into local superstition and custom, different everywhere, and some of the supposed virtues of the clergy had begun to drop off - such as sexual abstention, for instance. Philip and the Society of Jesus (or Jesuits, militant warriors of the Counter-Reformation) began to try and reform the situation. The Inquisition, which had run out of heretics to repress, began to focus more on the moral education of the people - and while the progress of this program varied from province to province, progress was indeed made. At the end of the century, though, the Spanish Church was largely unreformed. Massive damage had been done by the Inquisition's violent crackdown on un-Orthodox ideas - anything foreign was considered dangerous, and Spanish culture gradually became insular and backward when compared to the countries of the North.
Philip and the Papacy
The above was a source of some consternation for the various Popes which presided over the Holy See during Philip's reign as King of Spain - but the major bone of contention was no doubt Philip's foreign policy.
Most historians are agreed that Philip was a realist. There was a Medieval ideal of a strong Christendom united under one omnipotent ruler, and the Spanish race tended to think that this was its destiny. Philip, however, well aware of the true state of his finances and resources, saw as his goal the maintainence of high prestige but without commiting too heavily to maintaining absolute hegemony. As King of Spain, he was ennacting God's will anyway - he was not to be a mere puppet of the Pope.
The pontificate of Sixtus V (1585-90) brought things to their head. No fan of the Spanish and wary of Philip's imperialistic ambitions, Sixtus came close to excommunicating him. Henry IV (Henry of Navarre) took the throne of France in 1589, and he was a Protestant. Sixtus V promptly excommunicated him, but he refused to recognize Philip as the leader of the French Catholic opposition. Philip was furious, although probably not just because of dire religious convictions - the French certainly suspected him of advancing Imperial ambitions. In 1593 Henry IV converted to Catholicism with the famous phrase of realpolitik, "Paris is worth a Mass." Philip continued to oppose Henry's right to the throne even after the Papacy and Catholic nobles of France had done so. War was declared on Spain and in 1596 a triple alliance formed with England and the United Provinces. The Treaty of Vervins in 1598 is viewed by many historians as a great victory for France.
Philip and the Porte
The Porte was the court of the Ottoman Empire, and it was within this court that decisions affecting much of Christendom were made. When Philip came to power, the Sultan of the Ottoman Empire was Suleiman I ("the Magnificent") in power, and he would remain there until 1566. The Ottoman Navy of the Mediteranean had not been soundly defeated for a hundred years, and the Papacy was keen to see such a defeat inflicted; they paid Philip a sum known as the cruzada to finance such an endeavour. As for political aims, Philip was keen to retain Spanish territories in Northern Africa which secured good communications and trade between Spain and her Italian possessions. Throughout the 1560s and 70s, Turkish fleets and Barbary corsairs skirmished with Christian forces, besieging Malta in 1565 and capturing Algiers and Tunis.
The Papacy cried out for Spain's help in this hour of need, as it was reported the Turk would next strike in the heartland of Italy, Venice. Genoa, Florence and the Papacy formed a Holy League with which to resist the infidel, and Spain was offered the remission of clerical taxes worth one million ducats if it joined. Even given this incentive, Philip was unsure at first, and eventually only gave in because he knew his prestige would suffer if he did not join. At the Battle of Lepanto in 1571, a Christian fleet inflicted the most painful blow the Ottoman Navy had sustained since 1403. Philip was quick to grab the kudos, and the Papacy was happier with him than it had been for a long time.
This was not to last, however - the Papacy wanted Philip to follow up this victory by crushing the Turks even more resolutely, but Philip was keen to withdraw from the newly-pacified Mediteranean sphere to attend to his problems in Northern Europe. For their part, the Turks were keen to attend to their eastern front and Persia. So a truce was signed in 1580 and renewed a year later for a further three year period, and this enraged all of Christendom. Even the Spanish clergy called for the annulment of the cruzada. Philip had been forced to take this action out of pragmatism, however, and it did allow him to concentrate more on his campaigns against the heresy of the Netherlands.
Most Catholic King?
Although King Philip was not often able to meet the demands of the Papacy, he was a very devout and pious man who strived to do the best for the Catholic Church. His great power and resources were often directed by the influence of the Papacy against the heretic and the infidel, and his efforts to maintain his power arguably aided the Papacy in the long run. Within his own borders, he enjoyed one of the lowest levels of heresy in Europe, and although his close control of the Spanish Church often offended the Holy See it did allow him to control things from his close proximity. Even if he failed in the reform of his own Church, in matters of preventing abuses his was no worse than any other Church in Europe.