Although at least one Borg vessel is known to have passed through Federation space in 2364 and destroyed a number of outposts, the first known contact with this species occurred in 2365 when the Enterprise-D was catapulted into the J-25 system by Q. Although Q ultimately prevented the Borg from destroying the Enterprise, they apparently decided to attack the Federation after this encounter. A Borg ship arrived in 2366 and proceeded on course toward Earth.
The Federation responded by mobilising every Starship which could reach the battle zone in time, and a fleet of forty starships under Admiral Hanson met the Borg at the Wolf 359 system. The result was a total catastrophy; thirty nine of the forty ships where destroyed with the loss of some eleven thousand personnel and the Borg cube proceeded undamaged.
Initially much blame for this defeat was placed on Admiral Hanson, but over time it has become clear that there was little he could have done. The Borg had succeeded in capturing and assimilating Captain Picard prior to the battle, and had thus gained knowledge of Starfleets capabilities and combat tactics. In any case, the Borg cube untimately proved simply too powerful for the forces arrayed against it.
Although subsequent battles have been fought on a far grander scale with far larger forces, Wolf 359 came at a time when the Federation had not fought a major fleet action for decades. Large scale war was widely considered to be a thing of the past, and losses on this scale had not occurred in living memory. The psychological impact of the tragedy, followed by the imminent prospect of loosing Earth itself to the invaders, was at least as great as any since.
Following Wolf 359 Starfleet began a major effort to boost starship production and stepped up its recruiting efforts. In addition the Advanced Tactical Training school was established in order to create a core of highly skilled helm and tactical officers, and Starfleet began to recall many of its ships from deep space long duration exploratory missions to reinforce its borders at home. These measures have proven their worth in every subsequent conflict.