<PAGE>
                                                                    EXHIBIT 10.2

                             EMPLOYMENT AGREEMENT
                                        
                                        
     Agreement made as of the eighteenth day of  May, 1998 (the "Effective
Date"), by and between Peritus Software Services, Inc., a Massachusetts
corporation (the "Company"), and Peter Espinosa  (the "Employee").

     The Company wishes to employ the Employee, and the Employee wishes to
continue to  be employed by the Company.  In consideration of the mutual
covenants and promises contained herein, and other good and valuable
consideration, the receipt and sufficiency of which are hereby acknowledged by
the parties hereto, the parties agree as follows:

I.   Titles and Reporting Responsibilities
     -------------------------------------

      The Employee's title will be Vice President, Worldwide Sales or such
other title as may be mutually agreed upon between Employee and the Company. The
Employee will report to the CEO or, if there is no CEO, the President.

II. Term of Employment
    ------------------

      The Company hereby agrees to employ the Employee and the Employee hereby
accepts employment with the Company for a period (the "Employment Period")
commencing on the Effective Date and ending May 31, 2001 unless earlier
terminated pursuant to the provisions of Section VII below. This Agreement shall
remain in full force and effect until expiration hereof unless and until earlier
terminated in accordance with Section VII of this Agreement.

III. Responsibilities of the Employee
     --------------------------------

      The Employee agrees to undertake the duties and responsibilities inherent
in the position described in Section I above and such other duties and
responsibilities as the Company or its designee shall from time to time
reasonably assign. The Employee agrees to devote his entire business time,
attention and energies to the business and interests of the Company during the
term of this Agreement. The Employee agrees to abide by the rules, regulations,
instructions, personnel practices and policies of the Company and any changes
therein which may be adopted from time to time by the Company.

IV.  Expense Reimbursement
     ---------------------

      The Company will reimburse the Employee for all reasonable documented
travel and other business expenses incurred in furthering the business of the
Company and in accordance with the Company's then current travel and business
expense policy. Expenditures of an extraordinary nature shall require prior
written approval of the Company.

                                       1
<PAGE>
 
V.  Prohibitions
    ------------

      During the term of this Agreement, the Employee shall not:

      (a) be employed by or otherwise represent any other company, product,
      service or enterprise, without the prior written approval of the Company;
      or

      (b) make any representation, warranty, guarantee, or statement, orally or
      in writing, which would contravene any Company policy or compromise the
      Company's interests.

VI. Compensation
    ------------

      (a) The Employee shall be paid a base salary (the "Base Salary") and, when
      appropriate, bonuses (Bonus Compensation") as described in this Section
      VI. The Employee's bi-weekly Base Salary shall be $8,653.85, which is the
      equivalent of $225,000 per year. Provided neither party has exercised the
      right to terminate this Agreement under Section VII, performance and
      compensation reviews will be conducted annually beginning January 1, 1999.
      In addition, the Company will provide you with a relocation allowance of
      up to $60,000 in accordance with the Company's relocation policy.

      (b) Bonus Compensation may be paid from time to time to the Employee as
      approved by the Board of Directors of the Company, by a Committee of the
      Board of Directors of the Company established for the purpose of
      determining bonus compensation or by a designee of the Board of Directors
      or such Committee who has been granted the authority to determine bonuses.

      (c) Except as otherwise provided, the Employee shall be entitled to
      participate in any and all benefit programs that the Company establishes
      and makes generally available to its employees for which he may be
      eligible under plan documents and applicable laws. In any case where
      contributions or benefits related to participation in a plan vary on the
      basis of compensation, "compensation" shall mean Employee's Base Salary
      only and shall not include expense reimbursements, advances, Bonus
      Compensation or any other compensation which may be paid by the Company.
      The Employee shall be entitled to vacation in accordance with the
      Company's then current policy, to be taken at such times as may be
      approved by the CEO or, if there is no CEO, the President.

      (d) Any future revisions to Base Salary or Bonus Compensation may be
      implemented by the Board of Directors of the Company, by a Committee of
      the Board of Directors of the Company established for the purpose of
      determining bonus compensation or by a designee of the Board of Directors
      or such Committee who has been granted the authority to determine bonuses.

                                       2
<PAGE>
 
VII.  Termination
      -----------

      The employment of the Employee by the Company pursuant to this Agreement
shall terminate:

      (a) By the Employee, without cause, by giving 45 days' prior written
      notice of termination to the Company or within such shorter period as is
      established by mutual agreement of the parties or upon Employee's
      commencement of employment or consulting with a third party, or by the
      Company, without cause, upon at least 52 weeks prior written notice (the
      "Notice Period") of termination to the Employee.

      (b) By either party, if the other party breaches any of its obligations
      under this Agreement and fails to remedy such breach within 30 days after
      written notice of such breach is provided to such other party; failure of
      the Employee to adequately perform the duties and responsibilities
      specified in Section III hereof shall be considered a breach of this
      Agreement.

      (c) By the Company, effective immediately and without notice, for cause.
      For purposes of this Section VII (c), "cause" for termination shall be
      deemed to exist upon (a) good faith finding by the Company of the failure
      of the Employee to perform the assigned duties and responsibilities for
      the Company as specified in Section III above, dishonesty, gross
      negligence or misconduct, in which case the provisions of Section 7(b)
      shall not apply, or (b) the conviction of the Employee of, or the entry of
      a pleading of guilty or nolo contendere by the Employee to, any crime
      involving moral turpitude or any felony.

      (d) Upon the death or disability of the Employee. As used in this
      Agreement, the term "disability" shall mean the inability of the Employee,
      due to a physical or mental disability, to perform the essential functions
      of his/her job with or without a reasonable accommodation by the Company.

VIII. Rights Following Termination
      ----------------------------

      (a) Following termination of this Agreement, pursuant to Section VII(b),
      VII(c), VII(d), or at the option of the Employee pursuant to Section
      VII(a), or upon expiration of this Agreement, the Company shall have no
      further responsibility to Employee except to pay Base Salary up to and
      including the last day of employment.

      (b) Following termination of this Agreement at the option of the Company
      pursuant to Section VII(a), the Company shall continue to pay to the
      Employee the Base Salary in accordance with its then current payroll
      policies until the earlier of either expiration of the Notice Period or
      the date Employee commences employment or consulting with a third party
      during the Notice Period. Employee shall perform such services for the
      Company as mutually agreed upon between Company and Employee as to scope,
      timing and location during such Notice Period. The Employee shall not be
      eligible to receive the

                                       3
<PAGE>
 
      payments during the Notice Period unless and until the Employee signs a
      release in the form attached hereto as Exhibit A.

      (c) In the event of termination or expiration of this Agreement, Employee
      shall, at the instruction of the Company, promptly return to the Company
      or its designee all files, letters, memoranda, reports, records, data,
      sketches, drawings, laboratory notebooks, program listings, or other
      written, photographic, or other tangible material supplied by the Company
      to the Employee or created or maintained for the Company by the Employee.

      (d) Except as set forth above, neither party shall be entitled to any
      compensation or claim for goodwill or other loss, suffered by reason or
      termination of this Agreement.

      (e) The rights and obligations of the parties to this Agreement set forth
      in Section VIII and Section IX shall survive any termination or expiration
      of this Agreement. The termination or expiration of this Agreement shall
      in no case relieve either party from its obligations to pay to the other
      any monies accrued hereunder prior to such termination or expiration.

      (f) Employee shall not disclose the terms of this Agreement to any third
      party unless such third party is obligated to keep such information
      confidential.

IX.   Non-Competition
      ---------------

      (a) During the Employment Period and (i) for a period of one year after
          the termination of this Agreement pursuant to Sections VII(b), VII(c),
          VII(d) or at the option of the Employee pursuant to Section VII(a) or
          expiration thereof or (ii) in the event of termination of this
          Agreement by the Company without cause under Section VII (a) for the
          Notice Period, the Employee will not directly or indirectly:

          (i) as an individual, proprietor, partner, stockholder, officer,
      employee, director, joint venturer, investor, lender, or in any other
      capacity whatsoever (other than as the holder of not more than one percent
      (1%) of the total outstanding stock of a publicly held company), engage in
      the business of developing, producing, marketing or selling products or
      services of the kind or type developed or being developed, produced,
      marketed or sold by the Company or any subsidiary of the Company while the
      Employee was employed by the Company provided that the foregoing
      restriction shall not apply after the end of the Employment Period to
      activities that are not related to the Company's year 2000 business
      activities.; or

          (ii) recruit, solicit or induce, or attempt to induce, any employee or
      employees of the Company to terminate their employment with, or otherwise
      cease their relationship with, the Company; or

                                       4
<PAGE>
 
          (iii) solicit, divert or take away, or attempt to divert or take away,
      the business or patronage of any of the clients, customers or accounts, or
      prospective clients, customers or accounts, of the Company which were
      contacted, solicited, served or known by the Employee while employed by
      the Company.

      (b) If any restriction set forth in this Section IX is found by any court
      of competent jurisdiction to be unenforceable because it extends for too
      long a period of time or over too great a range of activities or in too
      broad a geographic area, it shall be interpreted to extend only over the
      maximum period of time, range of activities or geographic area as to which
      it may be enforceable.

      (c) The restrictions contained in this Section IX are necessary for the
      protection of the business and goodwill of the Company and are considered
      by the Employee to be reasonable for such purpose. The Employee agrees
      that any breach of this Section IX will cause the Company substantial and
      irrevocable damage and therefore, in the event of any such breach, in
      addition to such other remedies which may be available, the Company shall
      have the right to seek specific performance and injunctive relief.

X.    Other Agreements
      ----------------

      Employee represents that his performance of all the terms of this
Agreement and as an employee of the Company does not and will not breach any
employment agreement with any previous employer or any agreement with any
previous employer or other party to keep in confidence proprietary information,
knowledge or data acquired by him in accordance or in trust prior to his
employment with the Company or to refrain from competing, directly or
indirectly, with the business of such previous employer or any other party.
Employee has executed the Company's standard confidentiality and nondisclosure
agreement.

XI.   Notices
      -------

      All notices, requests, demands, and other communications under this
Agreement shall be in writing and shall be deemed to have been duly given when
delivered in person or, if mailed, when mailed by certified or registered mail,
postage prepaid, or by recorded delivery service to the parties at the addresses
set forth below their signatures to this Agreement or at such other address as
may be given in writing by either party to the other party in accordance with
this Section XI.

XII.  Assignability
      -------------

      Employee acknowledges that the Company is entering into this Agreement in
reliance upon the personal reputation, qualifications and abilities of the
Employee and accordingly, the Employee may not assign his rights or
obligations under this Agreement, either voluntary or by operation of law.

                                       5
<PAGE>
 
XIII. Miscellaneous
      -------------

      (a) This Agreement shall not be binding upon the Company until it has been
      executed by a duly authorized officer of the Company. This Agreement shall
      be binding on the parties and their respective successors and assigns.

      (b) This Agreement shall be governed by, and construed in accordance with,
      the substantive laws of The Commonwealth of Massachusetts.

      (c) This Agreement constitutes the entire understanding between the
      parties relating to the subject matter of this Agreement and supersedes
      all prior writings, negotiations or understanding with respect thereto
      except the confidentiality and nondisclosure agreement referenced in
      Section X above. No modification or addition to the Agreement shall have
      any effect unless it is set forth in writing and signed by both parties.

      (d) The waiver by the Company of any breach of any provision of this
      Agreement shall not be construed as a continuing waiver of such breach or
      as a waiver of other breaches of the same or of other provisions of this
      Agreement.

      (e) Should any provision of this Agreement be declared or be determined by
      any court of competent jurisdiction to be illegal or invalid, the validity
      of the remaining parts, terms, or provisions shall not be affected thereby
      and said illegal and invalid part, term or provision shall be deemed not
      to be a part of this Agreement.

      (f) The exercisability of Employee's options granted under the Company's
      1997 Stock Incentive Plan in the event of an "acquisition event" as such
      term is defined in such respective plan shall be governed by the terms of
      plan under which such options are granted and any related option
      agreements.

IN WITNESS WHEREOF, the parties hereto have executed this Agreement as of the
date first above written.

                                                 Peritus Software Services, Inc.



_____________________________________       By:_________________________________
Employee Signature

Address: 9123 West 145 Place                Address:  2 Federal Street
Overland Park, KS 66221                               Billerica, MA  01821-3540
                                                      Attn:  C.E.O.

                                       6
<PAGE>
 
                                   EXHIBIT A
                                   ---------
                                    RELEASE
                                        
1.  Release.     In consideration of the payments provided to me under a certain
    -------                                                                     
employment contract between Peritus Software Services, Inc., a Massachusetts
Corporation (the "Company") and me, I hereby fully, forever, irrevocably and
unconditionally release, remise and discharge the Company, and any subsidiary or
affiliated organization of the Company or their respective current or former
officers, directors, stockholders, corporate affiliates, attorneys, agents and
employees (the "Released Parties") from any and all claims, charges, complaints,
demands, actions, causes of action, suits, rights, debts, amounts of money,
promises, doings, omissions, damages, executions, obligations, liabilities, and
expenses (including attorneys' fees and costs), of every kind and nature, known
or unknown, which I ever had or now have against the Released Parties,
including, but not limited to, all claims arising out of my employment, all
claims arising out of your separation of my employment, all claims arising from
any failure to reemploy me, all claims of race, sex, national origin, handicap,
religious, sexual orientation, benefit and age discrimination, all employment
discrimination claims under Title VII of the Civil Rights Act of 1964, 42 U.S.C.
(S) 2000 et seq., the Age Discrimination in Employment Act, 29 U.S.C. (S) 621 et
seq., the Americans with Disabilities Act of 1990, 29 U.S.C. (S) 12101 et seq.,
The Employee Retirement Income Security Act of 1974, 29 U.S.C. (S) 1001 et seq.,
and similar state or local statutes, wrongful discharge claims, common law tort,
defamation, breach of contract and other common law claims, and any claims under
any other federal, state or local statutes or ordinances not expressly
referenced above.

2.  Entire Understanding and Applicable Law.     This Release contains and
    ---------------------------------------                               
constitutes my entire understanding with respect to the settlement of claims
against the Company and the Released Parties and cancels all previous oral and
written negotiations, agreements, commitments, and writings in connection
therewith.  This Release shall be governed by the substantive laws of The
Commonwealth of Massachusetts to the extent not preempted by federal law.

3.  Acknowledgements.  I acknowledge that I have been given at least twenty one
    ----------------                                                           
(21) days to consider this Release and that the Company advised me to consult
with any attorney of my own choosing prior to signing this Release.  I
acknowledge that I may revoke this Release for a period of seven (7) days after
signing it, and the Release shall not be effective or enforceable until the
expiration of this seven (7) day revocation period.



Date:__________________     Employee's Signature:______________________________
 
                            Employee's Name: Peter Espinosa

                                       7