Евгений is right. It happens only where one would expect И+Е and only in Dative and Prepositional.
Nominative/Accusative retain -ие.
-ИЯ (note dative):
Мария (Maria), Марии, МарИИ, Марию, Марией, о МарИИ.
Cf.: Ваня, Вани, Ване, Ваню, Ваней, о Ване.
братия, братии, братИИ, братию, братией, о братИИ.
(a collective noun, fraternity [of monks])
Юрий, Юрия, Юрию, Юрия, Юрием, о ЮрИИ.
(There nouns are mostly foreign: нация (nation), коронация (coronation) - those with -ion/-ia in English. Амфибрахий, Гай Юлий Цезарь.
Some like братия are slavic collective nouns)
Also neuter nouns on -ие:
Nom./Асс. пониманИЕ, Prep. о пониманИИ
These are mostly (some exceptions around) abstract nouns similar to English -ing gerunds: even здание=buildING.
You must have noticed that they have two spellings:
терпение and терпенье - both occur in books. 'patience'.
Наталья and Наталия - both occur in IDs.
And even the 'folkish' variant of Maria: Марья.
Unlike терпенье, most of 'long abstract nouns' occur in shortened -ье form in poetry, but in full -ие from in books.
Due to rythmic considerations I suppose, but both forms belong to the language.
And the opposite: some shorter and less abstract -ье nouns have an archaic -ие parallel variant:
счастие instead of счастье.
Normally -ИИ prepositional is chosen for 'full' -ие forms, and -ЬЕ for reduced.
But don't be surprised to meet Prep. "платьи":-)