We studied the risk for hip fracture before and after total knee replacement (TKR) in the entire population in Sweden. Women and men had a low risk for hip fracture before TKR but an increased risk the first year after TKR. Purpose It is known that osteoarthritis is associated with high bone mass. We therefore studied the risk of hip fracture before and after total knee replacement (TKR), risk of different hip fracture types, and risk subdivided in genders and age groups. Methods We followed the total Swedish population born between 1902 and 1952 (n = 4,258,934) during the period 1987-2002 and identified all patients with TKR due to primary OA (n = 39,291), and all patients with hip fracture (n = 195,860) in the Swedish National Inpatient Register. The risk time analyses were based on Poisson regression models. Results The hazard ratio (HR) for hip fracture the last year before TKR was 0.86 (95% CI 0.74 to 1.00) and the first year after 1.26 (95% CI 1.11 to 1.42) compared to individuals without TKR. The HR for femoral neck fracture 0-10 years after TKR was 0.95 (95% CI 0.89 to 1.01) and for trochanteric fracture was 1.13 (95% CI 1.06 to 1.21). The HR for hip fracture in the age group 50-74 was 1.28 (95% CI 1.14 to 1.43) and in the age group 75-90 years was 0.99 (95% CI 0.94 to 1.04) 0-10 years after TKR, compared to individuals without TKR. Conclusion Individuals had a low risk for hip fracture before TKR but an increased risk the first year after TKR. The risk in individuals below age 75 years and for trochanteric fractures was increased after TKR. Possible explanations include changed knee kinematics after a TKR, physical activity level, fall risk, and other unknown factors.