Obama appeared with O'Malley at Bowie State University in hopes of giving him a boost in his rematch with Republican former Gov. Robert Ehrlich. Obama said Democrats need to be "just as fired up as you were in 2008" when he was elected.
EMS personnel treated about three dozen complaining about dizziness and fainting spells at the event, Prince George's County Fire and EMS spokesman Mark Brady said. Two were taken to area hospitals, though they weren't seriously ill.
Most were suffering from exhaustion and dehydration, Brady said. Temperatures were in the 70s, and crowd members stood shoulder to shoulder in the sun. Most of those experiencing problems were seniors citizens.
Obama interrupted his speech to point out that someone in the crowd needed a hand. He joked that people should make sure they drink enough water and have enough to eat, particularly when they're going to hear politicians speak.
Earlier, several Maryland members of Congress, including House Majority Leader Steny Hoyer and Sen. Benjamin Cardin, spoke to the crowd of hundreds to warm them up for the president and the governor.
Voter turnout will be important, Maryland Attorney General Doug Gansler said. He urged the crowd to go to the polls. Gansler said if Maryland voters don't step up, the president could be surrounded by Republican governors, a reference to Virginia's Republican Gov. Bob McDonnell to the south of the nation's capital.
Fan, Follow and Text: Get the latest from NBCWashington.com anytime, anywhere. Follow us on Twitter and Facebook. Sign up for our e-mail newsletters and get breaking news delivered right to your mobile phone -- just text DCBREAKING to 622339 to sign up. (Message and data rates may apply.)