A loggerhead, in Shakespeare’s day, was a person whom today we would call a blockhead, probably derived from an old word, logger, meaning heavy or stupid, plus “head”.
But although Shakespeare used the term in that sense, the same word had a military meaning that was very different.
In this sense it applied to a ball-like mass of iron, with a long handle, which, when heated, was used to melt tar or pitch that might be poured onto the heads of a besieging party or to set fire to an attacking vessel.
The historical records do not say, but it is a logical assumption that the soldiers or sailors who were in charge of these operations with tar would, if the attackers came close enough, use their “loggerheads” as formidable weapons, bashing in such heads as came within reach.
We can reasonably assume, therefore, that our present-day use of “at loggerheads,” by which we mean “engaged in dispute,” originated from the use of a loggerhead in battle.