Apparently neither originated it. From Martin Luther: A Very Short Introduction by Scott H. Hendrix:
So far however, this statement has not been found in his writings. Scholars believe it originated in the German Confessing Church, which used it to inspire hope and perseverance during its opposition to the Nazi dictatorship.
Source
The statement then is normally attributed to Martin Luther (the German professor of theology, 1483-1546), but there is no documentation in his writings. Apparently it was attributed to him as early as 1944.
Greg Hewlett said:
Incidentally, there is some controversy as to the origin of this quote. Legend actually has Martin Luther saying this. But there is no written record of the reformer speaking these words. Apparently, the first written evidence of this saying comes from 1944 by a priest named Karl Lotz. In any case, it was MLK Jr who popularized the quote. I was introduced to the quote by my close friend, Rev. Mike Ernst, who told me of it when we first spoke of my cancer.
However, no proof is given that Martin Luther King, Jr. ever said it either.
Skye Jethian concurs:
Strangely, the line was used on more than one occasion by Martin Luther King Jr. as well and it sometimes falsely attributed as original. But that is neither here nor there.
Anyway, no documentation it was originated by either. May or may not have been used by Martin Luther King, Jr.