Believe it or not, the FBI has offices all over the world. According to the FBI's website, they "have 63 legal attaché offices — commonly known as legats — and more than two dozen smaller sub-offices in key cities around the globe, providing coverage for more than 180 countries."
Of course, the FBI can't just set up shop all willy nilly wherever they want. Before establishing an office, the FBI comes up with a mutual agreement with the host country. The office is usually in a U.S. embassy or consulate of that nation.
This program has been in place since 1940. Right before the attack on Pearl Harbor forced the United States to enter World War II, President Franklin D. Roosevelt decided America needed better intelligence in order to understand exactly what the Axis powers were up to.
Quick history lesson: The Axis powers were Italy, Japan, and Germany. At the time, the CIA wasn't a thing, and we had absolutely no footprint outside of the United States.
The FBI quickly realized that in order to further the exchange of information between countries, America had to put officials in the countries with which it was working. As luck would have it, in Aug. 1941, the U.S. Ambassador to Colombia "requested the assignment of a special agent to the U.S. Embassy in Bogota. This proved to be the forerunner of the FBI’s legal attaché, or legat, program."