The 31-year-old full-back will link up with his new club after his current deal with Ukrainian champions Shakhtar Donetsk expires on July 1.
Rat has spent the last 10 years in Ukraine, winning 15 trophies in total and has 88 international caps.
West Ham have the option to extend the deal to two or three years and his capture has delighted manager Sam Allardyce.
"I'm hugely happy that we've got a player of his experience and his character," the boss told the official West Ham website.
"He's been playing Champions League football this year and at the highest level for many years. Shakhtar had offered him a very good contract, but his ambition was to come and try his abilities and skills in England.
"When you hear somebody speak so positively about that, then you know they've got the mental character that's needed to do well in this division.
"We certainly know he's got the ability and he's at an age where he's still capable of producing at 31.
"He speaks perfect English, which he taught himself, and that shows the discipline and the character of the man. Discipline, character and ability are the three big things in the Premier League, and with a little bit of adjusting, we'll see him early on in the season giving hopefully his best performances for West Ham."
West Ham last week