I read almost the whole of Tale of two Cities without liking it as much as the other Dickens novels I'd read. The characters especially, with the exception of the Defarges, were supremely uninteresting. Then I came to the last pages and I already knew the plot, so was waiting with resignation for Sydney Carton's supreme sacrifice - and then he started his speech, and I was blown away! I felt I'd never read anything so moving in my life.
A similar thing happened with Tess of the Durbervilles. I found the characters and the idiotic things they did so annoying that I was ready to say I hated the book, but the end was wonderful. It seemed to elevate and beautify the whole book.