Explored and settled by the Spanish in the 16th century , Panama broke with Spain in 1821 and joined a union of Colombia , Ecuador , and Venezuela - named the Republic of Gran Colombia .