Rents hit another record high in June, putting more pressure on renters. But with the costs associated with buying a home rising so much this year, renting remains a better deal.

In June, the national median rent hit a new record high of $1,876 a month, up 14% from a year ago, according to Realtor.com’s rental report. While June marked the 16th consecutive month of record highs, it is the fifth straight month of moderating growth, retreating from a 17% year-over-year rent increase in January.

June’s median rent was $561 a month less, or 30% lower, than the typical monthly starter homeownership costs, according to the report. The difference is considerably greater than the $78 a month less that renters paid than buyers in January when mortgage rates were lower.

But since then, average mortgage rates have surged more than two percentage points, rising from 3.22% in January to 5.51% last week.

Although home prices also hit multiple record highs in the first half of the year, Realtor.com’s analysis found that mortgage rate hikes were the biggest driver of the widening affordability gap between renting and first-time buying.

“If not for higher mortgage rates, the rent versus first-time buying gap would have shrunk in the first half of this year, as rents grew more quickly than starter home prices,” said Danielle Hale, Realtor.com’s chief economist.

Higher mortgage rates added about $416 a month to typical starter home costs in June compared to a year ago, according to the analysis.

“As housing affordability remains a challenge for many Americans, it’s key to stay on top of how higher costs impact your budget, whether renting or first-time buying,” said Hale.

Buying vs renting

Among America’s 50 largest cities, 38 were considered relatively affordable compared to buying a starter home, up from 24 in January.

In some cities, the difference between the monthly cost to buy a home and the cost to rent is considerable, strongly favoring one or the other.

The top rent-favoring markets were dominated by the country’s biggest tech hubs, while the areas that favored first-time homeownership were concentrated in the Midwest and South.

Austin, Texas, showed the strongest case for renting over buying. Monthly first-time homeownership costs were $1,822 more, or 98% higher, than the median rental price there in June. Other cities where renting was far more compelling than buying last month were San Francisco; Seattle; New York; San Jose, California; Portland, Oregon; Los Angeles; Boston; Houston; and Phoenix.

Cities where buying a first home was more favorable than renting last month included Pittsburgh; Birmingham, Alabama; St. Louis; Cleveland; Baltimore; Louisville, Kentucky; Virginia Beach, Virginia; Indianapolis; Cincinnati; and Kansas City, Missouri.

“Many of these metros are also attracting home shoppers from out-of-state, in turn driving up the overall cost of living,” said Joel Berner, senior economic research analyst for Realtor.com. “For first-time buyers prioritizing lower home prices, you may still find options in these areas, but make sure to account for higher costs of other expenses in your budget.”