When Fairfax County was created in 1742, the first courthouse was located near modern Tysons Corner. The site of executions for criminals was nearby according to local legend - and that's why "Courthouse Road" and "Gallows Road" exist in that area.1
In 1749, five years after Fairfax County was established, the colonial General Assembly chartered the town of Alexandria in Fairfax County and the town of Dumfries in Prince William County.
Both towns were sponsored by Scottish merchants, and shared the same street names - King, Duke, Prince, etc. The Scottish merchants planned to establish commercial operations to buy tobacco in the colony of Virginia, and to pay for it immediately.
By paying for the tobacco directly, small farmers could purchase items immediately from the Scottish merchants' stores in Alexandria and Dumfries. This was a new business practice intended to compete with the traditional colonial pattern of consigning tobacco to agents in England..
Big planters like the Lees and Carters shipped their tobacco across the Atlantic Ocean, where their English agents sold the tobacco at what the Virginian's often considered a too-low bargain price. Along with the hogsheads of tobacco, the big planters sent orders for clothing, tools, wine, guns, and other items manufactured in Europe. The English agents purchased those items using the money from selling the tobacco, making a commision on the purchases as well. The big planters were accustomed to waiting up to a year to get their goods delivered, and many ended up going deep in debt by the time of the American Revolution.2
Alexandria quickly boomed as a seaport with direct connections to Europe. Shortly after its formation, the population of Alexandria had more political clout than the population in the western portion of Fairfax County. In 1752, when the 1742 courthouse needed to be replaced, the Alexandria merchants convinced county (and colonial officials in Williamsburg) to move the county seat to Alexandria. Naturally, residents in western Fairfax were disgruntled by the shift. They got a new Loudoun County created in 1757 with a courthouse in Leesburg, thus reducing the travel time required to go to the courthouse and transact business.
The eastern border of Loudoun County was defined by the headwaters of Difficult Run. From the mouth of that stream, a line was drawn south to the confluence of Cub Run and Bull Run, near modern-day Centreville.
The courthouse for Loudoun County was located at Leesburg, but the residents on the eastern edge of Loudoun County continued to do business in Alexandria. In 1798, a portion of eastern Loudoun County between Difficult Run and Sugarland Run was transferred back to Fairfax County. The mouth of Sugarland Run was designated as the starting point for a straight line cutting southwest to Carter's Mill on Bull Run.3
area moved from Loudoun to Fairfax in 1798 included lands between the mouths of Difficult Run and Sugarland Run (blue line is post-1798 boundary)
Source: ESRI, ArcGIS Online
Just two years later, the Fairfax County courthouse was moved 14 miles west to the new center of Fairfax County, after 32 square miles around Alexandria was ceded to the Federal government for inclusion within the District of Columbia. A move was necessary in 1800; the Fairfax County courthouse could not be located in a jurisdiction outside the state of Virginia.
The new courthouse was built in the town of Providence. It was not possible to name the community "Fairfax" because that name was already used to designate the county seat of Culpeper County. The name was appropriate there; the Fairfax family had arranged for George Washington to be appointed as the surveyor of Culpeper County.
Culpeper changed the name of its county seat in 1859, allowing Fairfax County to designate its county seat as the Town of Fairfax when it was incorporated in 1874.4
When the portion of the District of Columbia was "retroceded" or returned to the state of Virginia in 1847, the 32 square miles were not added back into Fairfax County. A new county was created, and Alexandria County built its own courthouse in the city of Alexandria. To reduce confusion between Alexandria County and Alexandria City, the county changed its name to Arlington County in 1920.
In 1961, when the Town of Fairfax became an independent city, Fairfax County had to prevent its courthouse from being located outside the jurisdiction of the county again. When the city boundaries were established, a small patch of land surrounding the county courthouse was excluded. As a result, there is a "hole in the doughnut" of Fairfax County land located inside the boundaries of the City of Fairfax. The historic and the current county courthouses, and some property next to the courthouses, still remains outside the city boundaries.
Fairfax has had three courthouses - one at "Springfields" near Tysons Corner, one in Alexandria, and one in what is now a patch of county land surrounded by the City of Fairfax. When other county operations became too cramped in offices shared with the judicial center, Fairfax County built a new "Government Center" west of the courthouse and moved most county staff to that location.
Prince William County has a similar history, with 5 separate courthouses as population centers have shifted. The Prince William County courthouse facilities are located within a small piece of county land surrounded by the City of Manassas, which became an independent jurisdiction in 1975. Most county offices are located at McCoart Administrative Center several miles to the east of the city, comparable to Government Center in Fairfax County.
In contrast, the county seat of Loudoun County has never moved since it was placed in Leesburg in 1757. Because Leesburg is a town and not a city, there is no "hole in the doughnut" pattern of boundaries. All f Leesburg is within Loudoun County, and not a separate jurisdiction.