simply because; on account of
Expresses that a preceding reason or cause led to an undesirable or unexpected result. Often carries a nuance of regret or criticism. Used with verbs, adjectives, and nouns in the plain form.
彼の言葉を信じたばかりに、大変なことになった。
Simply because I believed his words, things turned out terribly.
ちょっとしたミスをしたばかりに、プロジェクト全体が遅れてしまった。
Just because I made a small mistake, the whole project got delayed.
She hung her head as if she were about to burst into tears.
空は今にも雨が降り出さんばかりに暗くなった。
The sky darkened as if it were about to start raining at any moment.
ために also expresses cause, but is neutral and can be used for both positive and negative outcomes. ばかりに emphasizes that the cause led to an unfortunate result.
Derived from the particle ばかり (only, just) combined with the particle に. The exact historical development is uncertain, but the expression grammaticalized into a fixed adverbial phrase indicating cause or imminent action.