Who can be my third reference for doctoral applications? I am a postgraduate student in mathematics (if it matters) who is now also applying for doctoral positions, some of which require three references. 

It was a logical enough decision to select my academic advisor and my thesis supervisor to be my first two references, and they gladly accepted. However, attaining a third reference is proving much trickier. 

There was no immediate choice, so I decided to contact a lecturer of mine whose course I am currently following with whom I have quite a good relationship (as the class size is also small). Much to my disappointment, he wrote back to me only to decline and say that he does not know me nor my academic achievements well enough to provide a serious reference for me.

Now I am at a loss, because the only people who really know of my academic achievements are the two people who already agreed to be references for me; so where do I go from here?
Don't be shy. While this advice works in a million context, it is especially relevant here. The only way to know if you will get a good letter, is to interact closely with senior people in the field, gauge how much they liked your participation in their classes/your work in their lab, ask them the letter, gauge their response, choose the one that answers more enthusiastically. Your first two choices were the most obvious, now you should try with other lecturers you had. You certainly did not have just one lecturer in your studies! 

I was assistant professor in a research institution in my previous job, and can see several reasons why a lecturer might decide to write or not a letter for a candidate. You will never know them, you just have to ask, and use your social skills to predict whether it will be a good one.