Sales of the smartphones were a record for the three month period to June, the firm said, beating 26 million in the same period last year but down on the 37.4 million sold between January and March this year.
The company's quarterly profit of £4.49 billion (6.9 billion US dollars) was down from £5.73 billion (8.8 billion US dollars) in the same three months last year and down from £6.27 billion (9.56 billion US dollars) in the first quarter of this year.
Tim Cook, Apple's chief executive, said: "We are especially proud of our record June quarter iPhone sales of over 31 million and the strong growth in revenue from iTunes, Software and Services.
"We are really excited about the upcoming releases of iOS 7 and OS X Mavericks (operating systems), and we are laser-focused and working hard on some amazing new products that we will introduce in the fall and across 2014."
In April, Apple's profits slipped for the first time in a decade.
The company is facing strong competition from Samsung, which is growing on the back of the popularity of its Galaxy S4 handset.
In April the Korean manufacturer posted a 41% leap in earnings in the first quarter of this year - in the same week Apple reported its first annual slide in a decade.
Samsung made a net profit of 7.15 trillion Korean won (around £4.2 billion) for the period, up from 5.05 trillion won (around £2.9 billion) a year ago, attributed largely to a surge in sales of its smartphones.