Close contact with, especially in a military context - close contact with the enemy.
This term has a nautical origin. In the 17th century the barriers that sailors laid across a ship's deck in order to provide a safe haven from the enemy were called close-fights. Captain John Smith, in his record of early seafaring terms, The Seaman's Grammar, 1627 was good enough to define the term:
"A ships close fights, are smal ledges of wood laid crosse one another like the grates of iron in a prisons window, betwixt the maine mast, and the fore mast, and are called gratings."
By the mid 18th century that confined defensive space became called 'close quarters', that is, close dwellings. 'Close' in this context is confusing as it didn't mean 'near to', but was a variant of 'closed'. Nevertheless 'close quarters' came to mean 'near enough to to be able to fight hand to hand', which does match with our present day meaning of 'close by'.
In 1769 William Falconer published An universal dictionary of the marine. Given such an ambitious title we might expect 'close quarters' to be defined there and Falconer doesn't let us down:
"Close-quarters, certain strong barriers of wood stretching across a merchant-ship in several places. They are used as a place of retreat when a ship is boarded by her adversary, and are ... fitted with ... loop holes, through which to fire."
'Close quarters' was in wide use as a military by both sailors and soldiers for two centuries or more before it began to be used in other contexts. The earliest of these that I can find is from New improvements of planting and gardening, 1718:
... work should be done in the Winter, when the Snails are laid up in their close quarters.
The first reference that uses 'close quarters' just to mean 'close', that is, with no fighting or room alluded to is from The Times, 1819, in an exchange between the Lord Chancellor and a lawyer:
"Mr. Solicitor, we had better come to close quarters at once."
See other Nautical Phrases.