The road south to Peru passes right by Machala and heads down through Santa Rosa and Arenillas to the border town of Huaquillas, some 80km (50 miles) south of Machala. If you're going on to Peru, you should definitely use Machala, or even Guayaquil, as your final base in Ecuador because there are very limited services and no accommodations that I can recommend in Huaquillas. The Río Zarumilla forms the physical border between the two countries, and the Peruvian border town is Aguas Verdes. Both Ecuadorian and Peruvian immigration are always open. Keep in mind that the Ecuadorian immigration control point is located about 3.2km (2 miles) north of the actual border crossing, while its Peruvian counterpart is located about 2km (1 1/2 miles) south of the river. Both are on the main road and readily identified by numerous signs.
If you are heading south by bus, you should get off at the Ecuadorian immigration office to have your passport stamped. You can keep your ticket and then catch the next bus farther into town after you complete your border formalities. I recommend, however, that you take a taxi, which will only cost around $1 (55p). As you walk across the bridge that serves as the border crossing, you will have to show your stamped passport to Ecuadorian and Peruvian authorities. From here you can grab another taxi to the Peruvian immigration office to get your entry stamp. Most travelers head immediately to the town of Tumbes, which has far more facilities, services, and accommodations than Aguas Verdes. At the border crossing, you can hire a taxi for around $7 (£3.85) to take you to Tumbes, which includes a stop at the immigration office for you to get your stamp.
Note: The border is a hectic mess on both sides, and is relatively dangerous for travelers. Peru and Ecuador have had border disputes in the past, which hasn't helped matters. Keep a careful eye on your belongings, and be wary of hucksters and scam artists. Try to avoid and discourage touts. Scores of individuals offer money exchange in the streets on either side of the border, but I recommend exchanging a minimal amount there, because these dealers often give unfavorable rates, use rigged calculators, and pawn off counterfeit bills. It's best to have a good grasp of the current official exchange rate ($1/55p was equivalent to 3.20 soles at press time), and to see if you can exchange dollars for Peruvian soles at a bank in Machala. If not, exchange what you need to get you through to Tumbes, where you'll find more reputable and less risky exchange houses.