Talks focused on the economic crisis "that Spain is facing along with other European countries, which has provoked a grave employment crisis that involves many families, particularly the young," the Vatican said in a statement.
The role of the Roman Catholic Church in helping those most in need in Spain through charities like Cáritas was underlined during the talks.
Rajoy, a conservative who has been under fire for months over corruption allegations, also talked about the political situation in Spain with the new Argentine pope.
The two "reaffirmed the need for a dialogue in society and between all its components, based on mutual respect and taking into account values including justice and solidarity in a search for the common good," the Vatican said.
The statement added that the two men had discussed "the institution of marriage and the family and the importance of a religious education".
The Vatican is fiercely opposed to a Spanish law that allows same-sex marriages, passed under Rajoy's Socialist predecessor Jose Luis Zapatero.
The law also lets gay couples adopt children and inherit each others' property.
Polls show two-thirds of Spaniards back same-sex marriage.