Credit ratings are assigned by credit rating agencies based on a range of factors, including the borrower's credit history, financial strength, and ability to repay debt.