There are three basic kinds of foreign power: leased, run through and pay back.
If you are modeling the 1950's or earlier, unless it was joint track, it would most likely be leased power. Railroad A is short of power and railroad B has excess power, so A leases specific engines from B for a specific time.
As you go into the 1960's the run throughs become more prevalent. A run through is where railroad A operates a train that will be interchanged to railroad B and railroad B will operate the train, more or less in tact to someplace on railroad B. To keep from having to swap out engines, they two railroads agree to let the power run through and they will use each other's power, tracking it on a horsepower hours (hphr) basis. If the PRR uses 3 CB&Q SD40's for 50 hours that equals 450,000 hphrs (3 eng x 3000 hp x 50 hrs). Its not a lease per se, the engines are whatever is on the train and the time is however long it takes to make the run.
Once you start run throughs, you run into the problem of balancing the hphrs. If the CB&Q and the PRR have a run through and each railroad puts in 3 SD40's, but the trip to the PRR yard and back to interchange is 50 hours, but the trip to the CB&Q yard and back to interchange is 40 hours, the CB&Q engines will accrue more hphrs on the PRR than the PRR engines will accrue on the CB&Q.
That brings us to payback engines. In order to even out the imbalances, the railroad that owes hphrs will let the other railroad use some of its engines for a certain amount of time in order to accrue hphrs. In the above example the PRR will owe the CB&Q hphrs, so the PRR will let the Q use an engine or engines to pay back the hphrs. In the example above the difference is 10 hrs x 3 engines x 3000 hp or 90,000 hphr per day. If the PRR gives the Q an SD40 to use in general service that would be 1 engine x 24 hr x 3000 hp or 72,000 hphrs per day.
And it can get more complicated than that. In a former life I helped manage a railroad locomotive fleet and hphr balance was a major consideration.