The United States became a country on July 4, 1776, when the Continental Congress formally endorsed the Declaration of Independence. However, the first time a foreign country officially recognized the United States as independent was in 1777, when Morocco recognized the independence of the United States.