Until the establishment of the current CBP under Homeland Security, the Border Patrol and Customs were two separate agencies. For example in 1995 when taking the ferry from Victoria, we talked with a Border Patrol agent in Victoria before boarding, and passed through Customs in Port Angeles after. Airport entry was also a 2 step, one right after landing, the other after collecting our baggage.
One the first things Congress did in 1789 was to establish Collectors to "to regulate the Collection of the Duties imposed by law on the tonnage of ships or vessels, and on goods, wares and merchandises imported into the United States." For a century it was the main agency of the Treasury Dept, and customs duties were a major source of government income.
http://www.cbp.gov/xp/CustomsToday/2003/February/always.xmlThe Border Patrol is much younger, 1924 (dept of Labor), a creation of tigher immigration policies.
http://www.cbp.gov/xp/cgov/about/history/legacy/bp_historcut.xml