That's a big question.
The biggest difference is that with margin lending you actually own the stocks that you buy. Margin lending is not available for anything except company shares and managed funds. A margin loan is like a line of credit loan.
With a CFD you are entering in to a contract for price difference, only, on the underlying financial instrument. So you don't actually own anything. You can still receive a portion of dividends, but not franking credits. If you go short on a stock and hold overnight if dividends are paid, you have to pay the dividend out of your trading account.
CFD's tend to carry greater leverage, as you can have up to 99% leverage for index positions. Margin loans tend to top out at 80% LVR for margin calls.
The greater the leverage the greater potiential for losses.
To me, it seems CFD's are more suited to short term trading, and margin lending for longer term buy and hold investing, but that's just my humble opinion.