There was no law but it was tradition not to serve more than eight years started by George Washington.
I believe TR was the first president to try for a third, after a four year break, and FDR was the first to be elected for a third term. Yes I know Cleveland tried three times but was elected only twice, trying for a second term successfully after a first failed attempt at it.