Sancho VI inherited a debilitated kingdom, subject of frequent raids by the Kingdom of Castile of Alfonso VII and by the County of Barcelona of Ramon Berenguer IV, also king of Aragon, who in 1140 had agreed the partition of the kingdom in the Treaty of Carrión.