Prior to the 22nd Amendment (which set the term limit to two) there was one President who, notably, served four terms: Franklin D. Roosevelt won four elections, but passed away in the first year of his fourth term.
The 22nd Amendment was ratified in 1951 and makes a three-term presidency impossible unless the order of succession appoints a VP as President; in that case, if the new President serves two years (or less) of the original President's term, the new President may seek re-election twice for a total term limit of 10 years.
Both Grant and Theodore Roosevelt sought third terms, but were unsuccessful. Grant was unsuccessful in securing his party's nomination following a three-year hiatus from the Presidency, and Theodore Roosevelt lost to Woodrow Wilson in the general election.