The summer home of Maine's first governor, William King, at 40 Whiskeag Rd. is pictured. The home sold for nearly $1 million last week. Credit: Courtesy of Kate Sfeir

Maine is among the most expensive states to buy a home in the Northeast, a national ranking said.

U.S. News and World Report ranked the state sixth out of nine Northeastern states for housing affordability, saying it was less affordable than Pennsylvania, which was called the most affordable regionally, Connecticut, New Hampshire, New Jersey and Vermont.

Maine was still deemed more affordable than Massachusetts (ranked the least affordable in the Northeast), New York and Rhode Island.

Though the rankings utilize data from Moody’s Analytics that are a few years old, the numbers are another indication that Maine has transcended many of its Northeast neighbors in the cost of buying a home, especially in the highly competitive Portland Metro area.

The state moved ahead of Connecticut earlier this year in terms of median housing values, with homes in its border communities with New Hampshire also being typically more expensive than their Granite State counterparts as of recently.

Maine ranked better in the U.S. News and World Report’s cost of living estimate. It was ranked third in the Northeast, with only Pennsylvania and New York deemed less expensive. Iowa was ranked the most affordable state nationwide for housing while Hawaii was the least affordable.

Looking at standard single-family residential homes sold during the last week, homes sold for around $450,000 in Maine, Massachusetts and Pennsylvania provide the housing picture in each state.

In Maine, a two-bedroom home on a half-acre in Wells sold for $449,000 on Wednesday after being listed for 44 days. The home, which sold for its asking price, is a 35-minute drive from Portland and five minutes from Maine’s coast.

In Pennsylvania, a four-bedroom, 1-acre home in Landenberg around an hour southwest of Philadelphia and half an hour to the nearest river sold for $445,000 on Thursday after 43 days on the market. It sold for $46,000 above its asking price of $399,000.

In Massachusetts, a two-bedroom in Salem on 0.06 acres sold for $450,000 on Wednesday after being on the market for 48 days. Despite the listing saying it needed cosmetic updates, it still sold for $11,000 above its asking price. The home is around 40 minutes from Boston and a short distance from the water.