Flipping the action so the affected party is the subject
Japanese passive turns a normal action sentence around so that the affected party is the subject. Forms: る-verbs drop る and add 〜られる (食べる → 食べられる). う-verbs shift the final u-row sound to its a-row partner and add 〜れる (書く → 書かれる, 読む → 読まれる, 言う → 言われる). Irregulars: する → される, 来る → 来られる. Two flavors: (1) direct passive — something is done to you (財布 を 盗まれた = 'My wallet was stolen'); (2) indirect / adversity passive — something happened and affected you negatively even though you weren't the direct target (雨 に 降られた = 'I got rained on'). The agent (the doer) is marked with に.
Forming the passive — by verb class
る-verbs: drop る, add 〜られる. 食べる → 食べられる ('be eaten'). 見る → 見られる ('be seen'). おしえる → おしえられる ('be taught'). う-verbs: change the final syllable from the u-row to its a-row partner, then add 〜れる. 書く (ka-ku) → 書かれる (ka-ka-reru). 読む (yo-mu) → 読まれる. 話す → 話される. 言う → 言われる (note: う → わ, not あ). 待つ → 待たれる. 取る → 取られる. 死ぬ → 死なれる. Irregulars: する → される. 来る → 来られる (read こられる). All passive forms are themselves る-verbs, so they conjugate normally: 食べられる → 食べられた, 食べられて, 食べられない.
Direct passive — 'X was 〜ed (by Y)'
Standard passive use. The thing/person affected becomes the subject (often 私, often dropped). The agent — the doer — is marked with に. 私 は 先生 に ほめられました。 = 'I was praised by the teacher.' この 本 は 多く の 人 に 読まれて います。 = 'This book is read by many people.' 財布 を 盗まれました。 = 'My wallet was stolen.' (Note: even though the wallet was stolen, the speaker frames it from their own perspective as the affected party — so 財布 を, not 財布 が, with the implicit subject being 私.)
Indirect / adversity passive — 'I got 〜ed on'
Japanese has a passive that English doesn't really have: it lets you say someone else's action affected me (usually badly), even when I wasn't the grammatical object. 雨 に 降られました。 literally 'I was rained-on by the rain' = 'I got caught in the rain.' 赤ちゃん に 泣かれて、ねむれませんでした。 = 'The baby cried (on me), and I couldn't sleep.' 友だち に 来られて、しゅくだい が できませんでした。 = 'My friend came over (on me), and I couldn't do my homework.' The doer is marked with に, the verb goes passive, and the meaning is 'X happened, and I'm the one stuck dealing with it.' Often translated with 'got Xed on' or 'had X happen to me'.
Passive with body parts and possessions
When something is done to a part of you or a thing of yours, Japanese marks you as the subject and the part/thing with を. 足 を ふまれました。 = 'My foot was stepped on (literally: I was stepped-on as to the foot).' 頭 を なぐられました。 = 'I was hit on the head.' 車 を ぬすまれました。 = 'My car was stolen.' English would say 'My foot was stepped on'; Japanese says 'I was stepped-on the foot'. Same logic as the wallet example.
に vs. によって for the agent
For everyday passives, the agent is marked with に: 先生 に しかられました ('I was scolded by the teacher'). For creations — books, paintings, buildings, songs — the agent (creator) is often marked with によって instead: この 本 は 村上春樹 に よって 書かれました。 = 'This book was written by Murakami Haruki.' によって sounds more formal/written; に is fine for normal speech.
Same form, different meaning — passive vs. potential vs. respect
〜られる is a busy ending in Japanese: for る-verbs it's also the potential form ('can eat' = 食べられる) AND a 尊敬語 form ('eat (respectful)' = 食べられる). Three meanings, one form, disambiguated by context. 先生 は もう 食べられました か。 is almost always 'Did the teacher (already) eat?' (respect), not 'Was the teacher eaten?' (passive). この きのこ は 食べられます か。 is potential ('Are these mushrooms edible?'). For う-verbs, the three forms are different: 書ける (potential), 書かれる (passive), お書き に なる (respect) — so the ambiguity only really hits る-verbs.
