adverb
at the mercy of; as ... dictates; in accordance with
Used in the pattern ...のまにまに, meaning 'as ... dictates' or 'at the mercy of ...'. Often found in literary or poetic contexts, describing being carried along by natural forces or circumstances.
小舟は波のまにまに揺れていた。
The small boat was rocking at the mercy of the waves.
風のまにまに花びらが舞う。
Petals dance as the wind dictates.
ままに is more common and neutral, meaning 'as is' or 'leaving something as it is'. まにまに is more literary and emphasizes being at the mercy of something.
The exact derivation is uncertain; it may be related to the classical auxiliary verb まにま (meaning 'as' or 'while'), but the modern form is fossilized in the set phrase ...のまにまに.