Spain's King Juan Carlos and Queen Sofia attended the ceremony, CNN reported.
"This is the great task before us: to show everyone that God is a God of peace not of violence, of freedom not of coercion, of harmony not of discord," the pope said.
Benedict also decried the advance of secularism.
"I consider that the dedication of this church of the Sagrada Familia is an event of great importance, at a time in which man claims to be able to build his life without God, as if God had nothing to say to him," Benedict said.
The pope also praised the church's architect, Antoni Gaudi, for "overcoming the division between human consciousness and Christian consciousness, between living in this temporal world and being open to eternal life."
The church remains uncompleted after more than 100 years of construction. The pope is on his second visit to Spain, where the majority of the population considers itself Catholic.
Celebrity Families of 2014 [PHOTOS]