MADRID—Spain announced Friday it has nationalized three troubled banks that failed to meet new capital requirements and said the process of restructuring its financial sector is now complete.