Record high temperatures have been plaguing the Middle East, the mercury soaring to extreme levels during a blistering and unforgiving heat wave. Baghdad surged to its highest temperature ever recorded Tuesday.

Tuesday’s preliminary high of 125.2 degrees (51.8 Celsius) in Iraq’s capital city shatters its previous record of 123.8 degrees set on July 30, 2015, for any day of the year.

On Wednesday, Baghdad followed up with a temperature of 124 degrees, its second-highest temperature on record. On Monday, it had reached 123 degrees.

The crippling heat forced many residents indoors, and street sellers had to seek whatever shade they could find. With the state electricity grid failing, many households were relying on generators to power fridges, fans or air-conditioning units, the machines adding a guttural hum to the city’s already-noisy streets.

Two protesters were shot dead by security forces Monday during demonstrations over a lack of electricity and basic services amid the heat wave.

In nearby Lebanon, where a nationwide electricity crisis has left much of the country with less than three hours of state-provided power per day, the cost of a generator had doubled, leaving many households to go without.

Weather records expert Maximiliano Herrera tweeted that a location about 30 miles east of Beirut registered Lebanon’s highest temperature on record Tuesday, 113.7 degrees (45.4 Celsius), while additional locations in Iraq and Saudi Arabia also set records.

Herrera added that on Wednesday, Damascus, Syria’s capital city, tied its hottest temperature on record, hitting 114.8 degrees (46 Celsius).

More near-record temperatures in the 120s are likely Thursday in and around Baghdad before a slight moderation Friday. Highs to round out the week into the weekend should fall back into the upper 110s.

For comparison, the hottest temperature ever measured in Phoenix is 122 degrees in 1990. Records date back to 1895. Phoenix hasn’t made it to 120 degrees or greater since 1995.

The excessive heat can be attributed to a ridge of high pressure anchored over the Middle East, drifting west over the Red Sea toward Egypt. Beneath the “heat dome,” sinking air has warmed to extreme levels, while ridding the sky of any cloud cover that could offer the respite of brief cooling shade.

On Tuesday, the most intense part of the heat dome stretched from Israel and the eastern Mediterranean Sea to southern Israel and northern Saudi Arabia. That placed Baghdad under the core of the sweltering heat, while light clockwise winds around the high brought a gentle north-northwesterly breeze.

In Baghdad, a northwesterly breeze would bring in slightly more humid air from Lake Tharthar, which would acutely reduce the air’s ability to warm up. But a more northerly component to the wind, as occurred, draws in slightly drier air.

Temperatures this extreme heat the air up so much that it expands, meaning the height of a column of air grows taller in response to the warming. (It's the same reason an inflated balloon changes size based on the temperature.) The lower half of the atmosphere grew more than 280 feet taller than average on Tuesday thanks to the intense heating.

That expansion also causes the air to push outward more, explaining how “high pressure” systems get their name.

The high pressure ridge will shift southwest in the coming days, parking over central Egypt. Meanwhile, temperatures may warm into the upper 120s on Thursday over southeastern Mesopotamia near the Zagros Mountains in southwestern Iran.

While heat records can occur thanks solely to natural variability, they are disproportionately more likely to occur thanks to warming effects of climate change. Moreover, the human contribution of greenhouse gases to the atmosphere has knocked the earth’s relative balance of cold-and-warm anomalies off-kilter, skewing the planet strongly hot.

Several major international cities have notched their highest temperatures on record in the past several summers, including Paris, Montreal, Havana, Glasgow and San Francisco.

Mustafa Salim reported from Baghdad. Louisa Loveluck contributed to this article from Beirut. Jason Samenow contributed from Washington.