From Middle High German bīnāhe, bīnāch. Analysable as bei (“by, near”) + nah (“near, close”). Compare Dutch bijna.
beinahe